w3 total cache minification breaks wp_localize_script()

I am trying to configure W3 total cache plugin to speed up my site. The minify option is great but I am running into the following issue:
Let’s say I have a JavaScript file I am attached wp_localize script() to and it’s called 'additions.js'. Because W3TC minifies this JavaScript file and renames it, the wp_localize_script() function no longer sees my 'additions.js' file and the variables inside it don’t get shared with it.
Does anyone have a solution for this? Let me know if anything is unclear.

Related posts

Leave a Reply

1 comment

  1. W3 Total Cache has 4 locations to include the minified files. Since wp_localize_script() hooks into wp_head() (unless you specify in footer in your enqueue) you can use the before </body> minify location and your script will have access to the variables set. On some occasions this has failed for me so I just exclude the script from minify.