• Resolved rudolfl

    (@rudolfl)


    Hi,
    I am working on speeding up the site and I found that some scripts should be removed. One such example is CSS for Guttenberg blocks when I am not using Guttenberg. CSS is still added.

    I am hooking into ‘wp_enqueue_scripts’ and trying to dequeue those styles. This does not work because it seems AO already processed those files and included them.

    At the moment, I am solving it by adding relevant file to the AO list of files not to optimise and then my hook works normally.

    I have a feeling this is not the best way. Is there a hook I can use that is called after styles/scripts are loaded and before AO has a chance to process them?

    Thanks,
    Rudolf

Viewing 1 replies (of 1 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    That’s surprising, as AO works long after enqueuing (it captures WordPress’ HTML output and parses the JS CSS in the HTML) Rudolf, I don’t see how AO would stop you from dequeueing.

    But as a workaround there’s always the little-known autoptimize_filter_css_removables filter which you could hook into to return a comma-separated list of CSS to be removed (there’s a similar one for JS, obviously)? ??

Viewing 1 replies (of 1 total)
  • The topic ‘Dequeing scripts/styles’ is closed to new replies.