Title: Exclude wp_localize_script var
Last modified: April 23, 2026

---

# Exclude wp_localize_script var

 *  Resolved [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [1 month ago](https://wordpress.org/support/topic/exclude-wp_localize_script-var/)
 * When no caching / optimization is enabled I get a var wpslSettings = {} in the
   html source, but when I enable the LiteSpeed Cache plugin this var is gone and
   some code breaks. 
   I’m trying to make it so that when users use my plugin and
   activate the LiteSpeed Cache plugin that the wpslSettings var is automatically
   excluded from any form of minification / optimization, but I can’t really find
   any filters / documentation how to do this automatically.I’m using the three 
   filters that are mentioned [here](https://docs.litespeedtech.com/lscache/lscwp/api/#exclude-javascript-from-optimization)
   to exclude the js files from my plugin ( this works fine ) , but this doesn’t
   affect the wpslSettings var. It’s still being removed.What filter should I look
   at to prevent var wpslSettings = {} from being stripped in the output?
    -  This topic was modified 1 month ago by [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Support [litetim](https://wordpress.org/support/users/litetim/)
 * (@litetim)
 * [1 month ago](https://wordpress.org/support/topic/exclude-wp_localize_script-var/#post-18889234)
 * [@tijmensmit](https://wordpress.org/support/users/tijmensmit/) please send a 
   report to Litespeed and share the ID generated with me. This can be done following
   the steps: [https://docs.litespeedtech.com/lscache/lscwp/troubleshoot/#get-a-report-number](https://docs.litespeedtech.com/lscache/lscwp/troubleshoot/#get-a-report-number)
 * Also, are you able to share the code that uses the filters? You can share the
   code using ome of the sites: [https://pastebin.ubuntu.com/](https://pastebin.ubuntu.com/)
   OR [https://pastebin.com/](https://pastebin.com/) . Also, please write in which**
   action **it started loading(is a plugin/theme?).
 *  Plugin Support [litetim](https://wordpress.org/support/users/litetim/)
 * (@litetim)
 * [1 month ago](https://wordpress.org/support/topic/exclude-wp_localize_script-var/#post-18889255)
 * [@tijmensmit](https://wordpress.org/support/users/tijmensmit/) I made a test 
   and the code is doing it’s job.
   there are a few things you can test/do:Make sure
   that the php code is correct(the one from example is missing a **function** word).
   Make sure the value you want to exclude is correct. I would try: **wpslSettings**
   and see if that fixes the issue.Script priority is important too. Settings must
   appear before where the code is used.Also you can test if the code is working
   by going to the settings( example: [https://docs.litespeedtech.com/lscache/lscwp/pageopt/#js-excludes](https://docs.litespeedtech.com/lscache/lscwp/pageopt/#js-excludes))
   and see if the values appear in the correct settings.AND last thing: after changing
   JS files, combination will need to run. Clear all JS/CSS and refresh a page in
   incognito.
 *  Thread Starter [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [1 month ago](https://wordpress.org/support/topic/exclude-wp_localize_script-var/#post-18889658)
 * I fixed it by using the script_loader_tag filter to place the data-no-defer=”
   1″ attribute on the script tag that holds the wpslSettings var, now it works 
   fine 🙂
    -  This reply was modified 1 month ago by [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/).
 *  Plugin Support [litetim](https://wordpress.org/support/users/litetim/)
 * (@litetim)
 * [1 month ago](https://wordpress.org/support/topic/exclude-wp_localize_script-var/#post-18889675)
 * [@tijmensmit](https://wordpress.org/support/users/tijmensmit/) yes, it should
   do the trick. but is not the best solution. 
   Have you tried adding: **wpslSettings**
   to [https://docs.litespeedtech.com/lscache/lscwp/pageopt/#js-deferreddelayed-excludes](https://docs.litespeedtech.com/lscache/lscwp/pageopt/#js-deferreddelayed-excludes)?

Viewing 4 replies - 1 through 4 (of 4 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fexclude-wp_localize_script-var%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [litetim](https://wordpress.org/support/users/litetim/)
 * Last activity: [1 month ago](https://wordpress.org/support/topic/exclude-wp_localize_script-var/#post-18889675)
 * Status: resolved