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?

  • Is this your personal theme/site, or a public theme you're developing? Sep 6, 2011 at 0:03
  • Both, I guess! :) Sep 6, 2011 at 0:40

2 Answers 2

  • 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...


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:


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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