Proper way to enqueue a generated script that isn’t in a .js file?

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?

Related posts

1 comment

  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.

Comments are closed.