Footer scripts are not minified (with patch)
-
Hello,
An Akismet user who was using Siteground Optimizer notified us that the Akismet JavaScript that gets printed in the footer on some pages was not automatically minified by SO, even though it was not excluded from minification.
It appears that the
wp_print_footer_scripts
hook inLoader
fires too late for SO to modify the script registrations before they’re printed; instead, you could hook ontowp_footer
, which fires a little earlier. So the fix would be to change this, in core/Loader/Loader.php:add_action( 'wp_print_footer_scripts', array( $this->minifier, 'minify_scripts' ) );
to this:
add_action( 'wp_footer', array( $this->minifier, 'minify_scripts' ) );
The same applies to the CSS minification. Change this:
add_action( 'wp_print_footer_scripts', array( $this->minifier, 'minify_styles' ), 11 );
to this:
add_action( 'wp_footer', array( $this->minifier, 'minify_styles' ), 11 );
To test this, you could install Akismet and view the source of any page with a comment form. Without the patch, akismet-frontend.js in the footer will not be minified, but with the patch, it will.
Let me know if you have any questions
- The topic ‘Footer scripts are not minified (with patch)’ is closed to new replies.