WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What's the proper way for loading a script via WordPress that isn't in a .js file?
I'm generating some javascript on the fly based on some field options in a plugin. I want to load it into the page, but I want to do it the right way.

How should I proceed?

share|improve this question
This will help you wordpress.stackexchange.com/questions/24851/… – Vinod Dalvi Sep 9 '13 at 16:45
That great, wp_localize_script worked perfect. Nice and clean, thanks! – paper_robots Sep 9 '13 at 17:04
Add it as an answer ans accept it. – Vinod Dalvi Sep 9 '13 at 17:38

I ended up using wp_localize_script(). This allowed me just to send the PHP variables as parameters directly to a javascript file. Also useful for doing translations in javascript files. And then I didn't have to do messy inline javascript.

share|improve this answer

Your Answer


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.