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?


1 Answer 1


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.

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.