Some JS assets randomly not loading on cached pages
-
I have a problem with LSCache running on OpenLiteSpeed server, that my enqueued main theme JS file (and probably other JS assets as well) are randomly not loading on some cached pages, causing various problems (lazy loading not working on those pages (gray placeholders), scripts not running at all, etc.).
I have confirmed this by doing a simple console.log() on document ready event, which gets triggered on (almost) every page, instead the broken ones that don’t have JS loaded correctly.
Here’s my JS settings in Page Optimization:
- JS minify: ON
- JS combine: OFF
- JS combine external and inline: ON (but this shouldn’t have any effect since combine is disabled)
- JS defered: OFF
CSS seems to be loading fine everywhere, because I’m not noticing any layout/design problems. I am loading my JS assets like this:
wp_enqueue_script( 'app-js', get_stylesheet_directory_uri() . '/assets/js/app.js', array('jquery'), TEME_VERSION, true );
I can also see something is wrong when checking the Source tab in browser DevTools: If the page is cached correctly, I can see way more JS assets loaded in
/wp-content/litespeed/js/
. On incorrectly cached pages there are fewer JS files bundled/loaded.I’ve sent the plugin report as well, here’s the number: GJCCHNNO
What could be causing this and how to prevent it?
- You must be logged in to reply to this topic.