Conflicts with CSS/JavaScript Optimization

Please Note: This wiki is valid for v2.9.x and below of the LiteSpeed Cache Plugin for WordPress. If you are using v3.0 or above, please see the new documentation.

So, you enabled optimization features in LiteSpeed Cache for WordPress, and your site no longer displays correctly. It's a common problem, but it's probably not, strictly speaking, an issue with the LSCache plugin. Instead, it's more likely to be an issue with a single CSS or JavaScript file that conflicts with the Minification or Combination process.

This troubleshooting guide will help you find that problematic file yourself and exclude it from optimization.

(NOTE: If you really don't want to do the detective work yourself you can hire LiteSpeed to do it for you.)

Before we go to too much trouble, let's make sure that it really is an optimization issue. Turn off all optimization features, purge the cache, and check your site, like so:

  1. Turn off optimization. From the WordPress Dashboard, navigate to LiteSpeed Cache > Settings > Optimize and set all of the following to `OFF`: CSS Minify, CSS Combine, CSS HTTP/2 Push, JS Minify, JS Combine, JS HTTP/2 Push.
  2. Purge the cache. Navigate to LiteSpeed Cache > Manage > Purge and press the Purge All button.
  3. Check your site. Reload the page. Does it still look bad?

It still looks bad

If it's still not displaying correctly, then the problem is not with LSCache's optimization features.

What happens if you turn of LSCache completely? Does the site look fine? If so, then some other feature of LSCache is interfering with your site. Visit our forum, and let us know what's happening.

If the site is still messed-up even after turning off LSCache, then the issue is related to something else on your site and we, unfortunately, can't help. It's probably a good time to contact your hosting provider.

It looks good now

Congratulations, you have confirmed that the issue lies somewhere in the optimization features. Now you have two options:

  1. Leave those optimization options turned off for good. This is an easy solution, and if you choose to do this, your site can still benefit greatly from caching even without optimization enabled. Remember, you don't have to use combine and minify to use LSCache!
  2. Turn those options back on, do some troubleshooting to find the problematic file, and exclude that file from optimization. If you want to go this route, proceed to the next step.

The first step in finding the problematic file is determining whether we are looking at a JavaScript issue or a CSS issue.

Let's check JavaScript first:

  1. Re-enable the JS-related optimization functions, and leave the CSS functions disabled.
  2. Purge the cache again.
  3. View the page. How does it look?
  4. If it's messy, then one of your JS files is problematic. Jump ahead to Find and Exclude.
  5. If it's fine, then your JS files are also fine.

If JavaScript wasn't the culprit, then it's probably CSS. Let's verify.

  1. Disable the JS-related optimization functions, and re-enable the CSS functions.
  2. Purge the cache again.
  3. View the page. How does it look?
  4. It should be messy, indicating one of your CSS files is problematic.

Now that you know whether it's CSS or JS, you'll need to find the specific file that is causing the problem.

For the purposes of these instructions, let's assume you have a CSS file causing trouble. If, in fact, your issue is with JavaScript, you can still follow these same steps. Just imagine that the instructions say “JS” everywhere that they say “CSS.”

In order to find the file that is at fault, first we need to get a list of all possible CSS (or JS) files. Once that is done, we will exclude the entire list of files from optimization, and then reintroduce them one-by-one until we've found our culprit.

Get a List

Using the browser's Developer Tool, visit the Network tab, and click CSS to view only the CSS files. Reload the page. You should see a list of all of the CSS files in use by that page, listed in the Name column. Exclude everything on this list from optimization. (You can exclude files by full URL or by partial path.)

If you need to see the full path of any one CSS file, click on the name of that file, and click Headers. You will find the full location of the selected file listed as Request URL.

Test the List

  1. Enable all of the optimization functions you wish to use.
  2. Exclude all of the CSS files from optimization: Navigate to LiteSpeed Cache > Settings > Tuning and enter the files from your list, one-per-line, in the CSS Excludes box.
  3. Purge the cache and check the site. It should be displaying correctly.
  4. Remove one of the CSS files from the exclude list, and purge the cache.
  5. Check the site.
    1. If it still looks ok, then that file you just removed was not the problematic file.
    2. If the site looks broken, then you know you have found a problematic CSS file. Put it back in the box and leave it there.
    3. If there are more unchecked files, repeat from Step 4.

At the end of this process your site should look good, all of the optimization functions you wish to use should be enabled, and you should have one or more problematic CSS or JS files sitting the in the CSS Excludes or JS Excludes box and eliminated from future optimization.

Don't forget, if this feels like too much trouble, we can do it for you.

  • Admin
  • Last modified: 2020/05/04 13:50
  • by Shivam Saluja