Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there any real benefit to using wp_enqueue_script on small self-managed sites? For instance, Modernizr, why enqueue it through a function rather than call it directly inside the document head?

I can see the benefit on large sites, where you may move around directories or have multiple people mucking around in the files, or in a publicly available theme with numerous unknowns, but what's the benefit on a small site like a personal blog that never - or rarely - changes and has a single user? It just seems like extra lines of code in that case.

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted
  1. Are you using a Theme that you control?

    If not, then every time the Theme updates, you'll lose your modifications to the header. Or else, you'll have to fork the Theme, or maintain/backport your changes every time the Theme updates.

  2. Do you only use Plugins under your control?

    If not, then you'll have to check for script conflicts every time you activate or update a Plugin that uses a script.

  3. Are you using a core-bundled script?

    If so, then you'll have to check for core script conflicts every time you update core, as well as every time you update a Plugin that enqueues a core-bundled script.

  4. Do you use a caching Plugin?

    If so, then you lose some or all of the benefits of script concatenation/minimizing/caching, since your script is hard-coded in the document head rather than enqueued.

share|improve this answer
    
That pretty much covers it. I'm currently using 'enqueue' but I just find it...I don't know...unnecessary in this instance. Overkill? I don't know, every time I see it lately I'm find myself trying to justify it. –  TinySites Apr 15 '12 at 18:25
1  
Damn Chip I tried to beat you to the punch with my fancy title ;) –  Wyck Apr 15 '12 at 21:22
add comment
                                               **YES**

1. It only loads scripts when needed

Important for load speed.

2. It safely handles dependencies.

Reduces errors, duplicate loading and js clashing.

3. It handles load order and placement

Tell it where to load and when.

4. Its handles $src properly

Moving the site around, perfect.

5. It has versioning

Helps with caching and ..well versioning.

The "extra lines of code" is irrelevant, especially compared to the benefits of doing it right.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.