• How to delete CSS & JS before aggregated with Autoptimize?

    I’m trying this code, but it’s not working:

    function remove_unused_css_js(){
      if (!is_singular('portfolio')) {
        // Unregister JS files
        wp_deregister_script( 'jquery-magnificpopup' );
        wp_dequeue_script( 'jquery-magnificpopup' );
    
        // Unregister CSS file
        wp_deregister_style( 'magnific-popup' );
        wp_dequeue_style( 'magnific-popup' );
      }
    }
    add_action('wp_enqueue_scripts', 'remove_unused_css_js', 99);

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to delete CSS & JS before aggregated with Autoptimize?’ is closed to new replies.