How to find the right JS files to exclude from Breeze minification


#1

I found 2 errors when using javascript minification. How to exclude those file from minification? so I can use minification feature


#2

Hi @yokyliadinata

Could you elaborate on the nature of the JS error? Are they originating as a result of conflict between plugins OR between plugins and theme?


#3

yes, maybe it’s because of plugins or theme. My site works normal when javascript not minified

I will give you a screenshot


#4

I would advise to try out the merge+minify+refresh plugin. The big advantages of this plugin are:

  • it lists all the files it processes and you can find/exclude the ones causing problems
  • it will automatically reprocess them when one of them changes
  • the generated files have randomly chosen names, which means it works great with caching (you will automatically get the updated css/js because the newly generated file will have a different name)

On my sites, the only two files I’ve had to exclude are the following:

  • /wp-includes/js/jquery/jquery.js
  • /wp-includes/js/jquery/jquery-migrate.min.js

I have only enabled the following two options:

  • Enable HTTP2 Server Push
  • Enable Gzip Encoding

I hope this helps.


#5

Thanks, I’ll try that. I should disable minify from breeze first right?


#6

@therealgilles Just try it recently, then do speed test with gtmetrix. My request is decrease from 79 to 61, great!
But I’m not sure I have set the right configuration. Please help me with this questions:

  1. Currently Breeze plugin still active. Gzip Compression & Browser Cache is enabled. Do I still need enabling gzip encoding in merge+minify+refresh plugin? and How about http2 server push?
  2. I’m also using woocommerce, is there any special configuration when using merge+minify+refresh plugin? what to exclude?
  3. Why you exclude this?
  • /wp-includes/js/jquery/jquery.js
  • /wp-includes/js/jquery/jquery-migrate.min.js

Thanks!


#7

@yokyliadinata, yes it is better not to try to minify files multiple times.


#8

@yokyliadinata, try not to duplicate the functionality.

  1. If you have gzip compression in Breeze, do not enable it in merge+minify+refresh. I believe Cloudways does not support http2 at this point, so I am guessing it won’t do anything by itself. I use Cloudflare as CDN and they support http2, so it may have an effect in this case, not 100% sure. I would highly recommend using Cloudflare or a similar service as CDN (Cloudflare is free for most things and they have a lot of options you can tweak).

  2. Nothing special for Woocommerce. FYI I use it too.

  3. I had to exclude jquery.js and jquery-migrate.min.js due to loading order issues. I forgot to mention that I also use the code below in functions.php to defer javascript loading:

    // Defer javascripts (except jquery.js)
    if (!is_admin()) {
      function defer_parsing_of_js ( $url ) {
        if ( FALSE === strpos( $url, '.js' ) ) return $url;
        if ( strpos( $url, 'jquery.js' ) ) return $url;
        return "$url' defer onload='";
      }
      add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
    }
    

I am guessing the necessity to exclude jquery.js is because some of the plugins I use do not specify a correct dependency on jquery when enqueue their javascript files or they use inline javascript code using jQuery.

Question: what metric/units are you using when you talk about ‘79’ and ‘61’ for your request?

PS: If you haven’t done it yet, make sure you run wp-cron as a cron job and set the following in wp-config.php:

   define('DISABLE_WP_CRON', true);

I run my wp-cron job every minute with the following url:

   https://<site-url>/wp-cron.php?doing_wp_cron

Replace with your own site url. This made a huge difference on one of my sites.

PS1: You can also try to set the following variables in wp-config.php:

   define('OTGS_DISABLE_AUTO_UPDATES', true);
   define('CONCATENATE_SCRIPTS', true);

#9

Hi @yokyliadinata

kindly share your Credentials than i will look into it.