Is it possible to use wp_localize_script to create global JS variables without a specific script handle?

Posted by Prem Tiwari | Updated on

Instead of using wp_localize_script in that case, you can hook your js variables at wp_head, that way it would be available to all js files like:

You should json encode the variables:

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@] Your question and answer will appear on and help other developers.

Related Questions & Answers