Remove a certain style by its enqueue handle name
-
I can see this exclusion field on CSS Options: Exclude CSS from Autoptimize.
This field allows to exclude files of being optimized.
But, do your awesome plugin has a filter to exclude a specific style from compilation by its “handle” name? For example, I have this inline style:
wp_register_style( 'cpxt-loading-handle', false ); wp_enqueue_style( 'cpxt-loading-handle' ); wp_add_inline_style( 'cpxt-loading-handle', $css_code );
This will magically force WordPress to add the ‘cpxt-loading-handle’ inline style without depend of a parallel CSS file enqueue.
The handle name in this case: ‘cpxt-loading-handle’.
I’m looking by something like this:
add_filter( 'autoptimize_filter_handle_css', 'cpxt_exclude_handles_from_autoptimize', 10 , 1 ); function cpxt_exclude_handles_from_autoptimize( $handles_array ) { $key = array_search( 'cpxt-loading-handle', $handles_array ); if( false !== $key ) { unset( $handles_array[ $key ] ); } return $handles_array; }
Waiting your feedback, thanks in advance.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Remove a certain style by its enqueue handle name’ is closed to new replies.