• Hi,

    I’ve been struggling with unloading unused css files for weeks when I came across this plugin. And while it helped me remove almost everything I wanted, a few stylesheets remain which I just can’t find a way to unload.

    For example, I’m running the Neve theme and I wanted to unload it’s main stylesheet style-main.min.css because I wrote my own and already enqueued it instead of the original one. But there are some ‘children’ css files depending on this file as your plugin correctly established, so I checked the “ignore dependency rule” to keep these children loaded. But with this checked, the style-main.min.css is still loaded as well.

    Here are two screenshots showing my settings and the coverage of the files loaded:
    plugin settings
    coverage screenshot in Chrome devtools

    Apparently I can wither unload the css file and all its dependencies or keep them all loaded by checking the “ignore dependency rule”. Any idea as to what I’m doing wrong?

    Note: I’m working in test mode.
    Note2: I’m having the same issue with Elementor’s custom-frontend.min.css and frontend-legacy.min.css, which also have dependencies

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter adamovic

    (@adamovic)

    There’s one more thing I noticed: whether I keep the style-main.min.css loaded or unloaded, the coverage tool in Chrome devtools shows exactly the same css and JS files loaded on the page. But there are clear visual differences in how the page loads nevertheless. Any idea where those differences come from?
    Here’s a screenshot.

    Plugin Author Gabe Livan

    (@gabelivan)

    @adamovic

    But with this checked, the style-main.min.css is still loaded as well.

    Based on the print screens you attached, the file should not be loaded at all. Only style.css (from these two) should load fine. Are you sure you cleared the caching (if you’re using a page caching plugin) and test it out while you’re logged in? Perhaps you had “Test Mode” on and you made a test as a guest (all assets would load then).

    Perhaps it’s a bug indeed from Asset CleanUp! I’ll make a few tests and get back to you!

    UPDATE: Everything is working smoothly on my tests and this has never been reported by other users, making me think this is an isolated case. Let me know how the testing is going on (the one I mentioned you could do)!

    Thread Starter adamovic

    (@adamovic)

    Hi @gabelivan ,

    Thank you for your response.

    I tried as you said, I cleared the cache (currently I only have Autoptimize active, otherwise I’m also using WP Fastest Cache, but I have it deactivated while I’m optmimizing my CSS and JS). I checked again in Chrome, where I’m always logged in, and also in Edge, which I otherwise don’t use (just in case my browsers cache could interfere somehow).

    But the issue persists. I’m sending another screenshot.

    Do you have any other idea what I could try?

    Plugin Author Gabe Livan

    (@gabelivan)

    @adamovic if the option to ignore the dependency files (not to also be unloaded) is chosen, then the stripping of the targeted file (the one with the site-wide rule in place) is done via “wp_loaded” and not by dequeuing. I have a suspicion that for some reason, Asset CleanUp is not triggering that code. Can you enable minify/combine CSS and let me know if there are any files loaded from the /wp-content/cache/asset-cleanup/? If they are not (and you already checked in Incognito), then it’s a problem somewhere (e.g. a PHP error in one of the “wp_loaded” hooks, perhaps from another plugin) and has to be fixed. Otherwise, I can’t think of anything that would interfere with it. This has been working well so far without any complaints and worked fine on my recent test.

    Thread Starter adamovic

    (@adamovic)

    When I enable minify/combine, I see 2 files loaded from the asset-cleanup folder.

    In case we don’t figure this out, I could still try to unload the files manually in functions.php, but I’m not sure how to do that when there are dependencies included and I can’t use dequeue. Which function is used to unload via wp_loaded?

    Thread Starter adamovic

    (@adamovic)

    I’m looking at my website again by applying different settings and there seems to be a slight difference anyway, which I think should not be there.

    This is a screenshot with the combine option switched ON.
    And this is a screenshot with the combine option OFF.

    Notice the header of my page, which is targeted by the CSS file, we’re trying to unload properly. All unload/dequeue settings are the same in both cases above, so style-main.min.css is set to unload sitewide but with dependencies kept loaded.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Unload stylesheet site-wide and ignore dependency rule’ is closed to new replies.