• 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 in Loader fires too late for SO to modify the script registrations before they’re printed; instead, you could hook onto wp_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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Gergana Petrova

    (@gpetrova)

    Hello @cfinke,

    Thank you for the report.

    I was able to recreate the issue and to test the fix. I have passed the information to our Developers, who will further check and see if we can proceed with applying the fix in one of the future releases of the plugin.

    Best Regards,
    Gergana Petrova

    Plugin Support Gergana Petrova

    (@gpetrova)

    Hello @cfinke

    We have setup a default WordPress application with both SiteGround Optimizer and Akismet plugins. Then tested the case on a contact form page as suggested.

    The script you are reffering to akismet-frontend.js is properly minified – there is a minified JS file created from it under wp-content/uploads/siteground-optimizer-assets/akismet-frontend.min.js and the script is fully minified withing the file.

    I can see you are mentioning that the JS under page source inspection is not minified – for the case you can enable Minify HTML Output from the plugin interface, so this code to be minified as well. 

    You can verify the results on your end.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Footer scripts are not minified (with patch)’ is closed to new replies.