Caching Exclusions
PersonalizeWP works with all caching plugins and services, but you may also need to ensure that you have excluded specific files in your cache options.
To ensure the plugin works seamlessly on your WordPress site, follow these steps to exclude PersonalizeWP’s essential files from being deferred, minified, or removed as unused assets.
PersonalizeWP Javascript Files
PersonalizeWP uses custom Javascript to manage features such as showing/hiding content, tracking users and implementing password functionality.
Each of our JS files has a 'defer' strategy so that the page DOM finishes parsing before we execute the scripts. This allows the scripts to look at the page content that has been loaded and take action based upon what it finds.
Many sites choose to minify or concatenate JS scripts into a single file without a 'defer' tag. If our PersonalizeWP JS is included it in this, it means that our code is executed earlier than it should be, and this can lead to errors or content not showing.
With this in mind, you need to ensure that our JS scripts are excluded from your concatenation, and update any cache plugin settings to do this.
If you are running PersonalizeWP Lite only, then you need to exclude this file:
- /wp-content/plugins/personalizewp/public/js/pwp.js
If you are running PersonalizeWP Pro, you need to exclude these all of these files:
- /wp-content/plugins/personalizewp/public/js/pwp.js
- /wp-content/plugins/personalizewp-pro/public/js/content-variations.js
- /wp-content/plugins/personalizewp-pro/public/js/pwd-blocks.js
- /wp-content/plugins/personalizewp-pro/public/js/tracking.js
- /wp-content/plugins/personalizewp-pro/public/js/visitor-data.js
If you would like to implement these as wildcards (for instance like WP Rocket uses), you could use the following:
- /wp-content/plugins/personalizewp/public/js/(.*).js
- /wp-content/plugins/personalizewp-pro/public/js/(.*).js
WordPress VIP Hosting
If you are using WordPress VIP as your hosting solution, and you are concatenating your files, you can use this code:
add_filter( 'js_do_concat', 'my_vip_js_concat_filter', 10, 2 ); function my_vip_js_concat_filter( $do_concat, $handle ) { if ( str_contains( $handle, 'personalizewp' ) ) { return false; } return $do_concat; }
This will allow each file to be downloaded correctly with 'defer' in place, allowing them to execute at the correct time.