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.

My Wordpress theme has a lot of .js scripts running and it takes plenty of time to load them all one by one. I would love to use a script loader like HeadJS or yepnopejs to speed things up.

But... what about wp_enqueue_script? I'm using it to load every single script (and I believe that's the BEST & ONLY way to go?).

Won't loading scripts using script loader instead of wp_enqueue_script create any conflicts with plugins, widgets etc.?

What about enqueuing the script loader itself?

share|improve this question
    
Is this your personal theme/site, or a public theme you're developing? –  onetrickpony Sep 6 '11 at 0:03
    
Both, I guess! :) –  Wordpressor Sep 6 '11 at 0:40
add comment

2 Answers 2

up vote 0 down vote accepted
  • If this is for your personal blog only, then just use a plugin that minifies and concatenates JS.

  • If it's for a theme you're building, then if the scripts are custom, or small & unlikely to be used by other plugins, merge them all into a single .js file, and load it in the footer.

    A more hardcore method would be to pick up registered scripts from the $wp_scripts global, unregister them all, and concatenate them into one file (or load them with headjs, whatever way you want to go). Here are some ideas if you go this way...

share|improve this answer
add comment

Building off of the code that @OneTrickPony provided, I came up with a solution for this that works pretty well for me. I posted it as an answer to another similar question here:

http://wordpress.stackexchange.com/a/40325/9802

I hope it helps someone, and if you see any issues please leave me a comment on that other thread.

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.