Have .js script loaded AFTER wp_localize_script




Wordpress LScache Plugin: Have .js script loaded AFTER wp_localize_script

Last Updated on: Wed, 15 Apr 2026 00:00:02
I notice I get psyOptions is not defined errors, if I enable combine JS files feature. As far as I could see, this is because the script is loaded BEFORE the psyOptions = is set in the HTML. The plugin (in this case PixelYourSite) uses wp_localize_script, as well as our own theme, and it seems this wont work, unless the javascript is loaded AFTER wp_localize_script has been set. Could you work on this? Or is there already a setting to change this? Usually Id prefer if javascript scripts is loaded in the footer ,instead of the header. Hi @mattiasf, our JS combine function will separate the JS from header or footer. Could you please check is the Combined JS Priority option turned OFF? If it still not work you can exclude the JS which need to use psyOption var by putting it on JS Excludes or move that file to footer by $in_footer var on wp_enqueue_script() function. Hey, yes Combined JS Priority was turned off, turning it ON didnt fix the error. Can I exclude the file like this? /wp-content/plugins/assets/somefile.js Or does it have to be somefile.js or the full link? You may enter full URLs or a partial string. somefile.js is fine if therere no other JS files contain the same name. OK. I tried earlier with a partial string, but it didnt seem to work. Anyhow, would it make sense to make a move scripts to bottom of page feature? As many other optimization plugins have it. Thanks for the suggestion, I will discuss with the development team on this issue. The reason why we do not have this option is that the JS is combined sequentially base on the on HTML, but its excluded the inline JS so causing your problem. Please try to enqueue with $in_footer or make psyOptions = in a file for your issue.



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference