Troubleshooting

Caching and Speed Plugin Issues

WordPress caching and performance optimisation plugins can interfere with SourceTag by minifying, combining, or deferring its JavaScript. This page covers the most common plugins and how to exclude SourceTag from their optimisations.

How caching plugins cause problems

These plugins improve page speed by doing things like:

  • Minifying JavaScript (removing whitespace and shortening variable names)
  • Combining JavaScript (merging multiple script files into one)
  • Deferring JavaScript (delaying script execution until after the page renders)
  • Lazy-loading scripts (only loading scripts when they’re needed)

While these optimisations are great for performance, they can break SourceTag in several ways:

  • Minification might corrupt the script if the minifier doesn’t handle the IIFE correctly
  • Combining it with other scripts can introduce conflicts
  • Deferring it too late means the script runs after form elements are already in the DOM but after the user has started interacting
  • Lazy-loading might prevent it from running at all on pages without visible triggers

What to do

Exclude the SourceTag script from all JavaScript optimisations. You can identify the script by its URL:

cdn.sourcetag.io/scripts/

or by the filename:

st.js

Below are the specific exclusion steps for the most common plugins.

WP Rocket

  1. Go to Settings > WP Rocket
  2. Click the File Optimization tab
  3. Scroll to JavaScript Files
  4. In the Excluded JavaScript Files textarea, add:
cdn.sourcetag.io/scripts/
  1. If you also use the “Delay JavaScript execution” feature, add the same URL to the Excluded JavaScript Files list in that section
  2. Save Changes
  3. Clear the WP Rocket cache

[IMAGE: Screenshot of WP Rocket File Optimization settings with the SourceTag script URL in the exclusion list]

Autoptimize

  1. Go to Settings > Autoptimize
  2. Click the JS, CSS & HTML tab
  3. In the Exclude scripts from Autoptimize field, add:
cdn.sourcetag.io/scripts/
  1. Save Changes and Empty Cache

If you have “Aggregate JS-files” enabled, the exclusion will prevent SourceTag from being merged into the combined file. If you have “Also aggregate inline JS” enabled, make sure it doesn’t affect the SourceTag configuration.

[IMAGE: Screenshot of Autoptimize JS settings with the exclusion field highlighted]

LiteSpeed Cache

  1. Go to LiteSpeed Cache > Page Optimization
  2. Click the Tuning tab
  3. In the JS Excludes textarea, add:
cdn.sourcetag.io/scripts/
  1. If you’re using the “JS Defer” or “JS Delayed” features, also add the URL to the JS Deferred Excludes field
  2. Save Changes
  3. Purge the LiteSpeed cache

[IMAGE: Screenshot of LiteSpeed Cache Page Optimization Tuning tab with the JS Excludes field]

W3 Total Cache

  1. Go to Performance > Minify
  2. In the JS section, find Never minify the following JS files
  3. Add:
cdn.sourcetag.io/scripts/
  1. Save all settings
  2. Purge all caches from Performance > Dashboard

[IMAGE: Screenshot of W3 Total Cache Minify settings with the JS exclusion field]

SG Optimizer (SiteGround)

  1. Go to SG Optimizer > Frontend Optimization
  2. Under JavaScript, find the “Exclude Scripts from being combined” or “Exclude Scripts from Minification” option
  3. Add:
cdn.sourcetag.io
  1. Save and purge the cache

WP Fastest Cache

  1. Go to WP Fastest Cache > Settings
  2. If “Combine JS” or “Minify JS” is enabled, click the corresponding settings icon
  3. Add cdn.sourcetag.io to the exclusion list
  4. Save and delete the cache

Perfmatters

  1. Go to Settings > Perfmatters > Assets
  2. Under “Delay JavaScript”, add cdn.sourcetag.io to the exclusion list
  3. Save Changes

General approach for other plugins

If your caching or optimisation plugin isn’t listed above, look for settings related to:

  • JavaScript minification exclusions
  • JavaScript combination/aggregation exclusions
  • Script defer/delay exclusions

Add cdn.sourcetag.io/scripts/ or st.js to the relevant exclusion list.

If you’re using a CNAME to serve the script from your own domain (e.g. scripts.yoursite.com), use that URL in the exclusion instead.

How to tell if caching is the problem

If SourceTag works after clearing the cache but stops working once the cache rebuilds, a caching plugin is likely the cause. Other signs:

  • The script works in incognito mode (where cached resources are often bypassed) but not in a normal browser session
  • The st.js file appears in the Network panel but its contents look different from the original (minified in an unexpected way, or bundled with other scripts)
  • JavaScript errors appear in the console mentioning the SourceTag script after optimisation

Further reading