Title: Dequeing scripts/styles
Last modified: January 20, 2022

---

# Dequeing scripts/styles

 *  Resolved [rudolfl](https://wordpress.org/support/users/rudolfl/)
 * (@rudolfl)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/dequeing-scripts-styles/)
 * 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](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/dequeing-scripts-styles/#post-15272713)
 * 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.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [4 years, 4 months ago](https://wordpress.org/support/topic/dequeing-scripts-styles/#post-15272713)
 * Status: resolved