Skip to content

Hawksama/magento-2-performance-optimization

Repository files navigation

Google Page Speed Performance Optimization

``hawksama/magento-2-performance-optimization``

Main Functionalities

Google Page Speed optimizer.

Main features

  • Eliminates render-blocking CSS files by asynchronously loading CSS using RequireJS.
  • Minifies the HTML without affecting KnockoutJs, RequireJs, jQuery or VanillaJs.
  • Moves all script tags with either the src attribute or inline scripts that are loaded in the source page at the bottom of the page before closing </body> with the ability to skip some pages or controllers.
  • Adds custom critical.css file to improve First Contentful Paint score. Extends the Magento 2.3.3 functionality CSS critical path to be compatible with the new CSS asynchronously mode.

Installation

* = in production please use the --keep-generated option

Type 1: Zip file

  • Unzip the zip file in app/code/Hawksama
  • Enable the module by running php bin/magento module:enable Hawksama_PerformanceOptimization
  • Apply database updates by running php bin/magento setup:upgrade*
  • Flush the cache by running php bin/magento cache:flush

Type 2: Composer

  • Install the module composer by running composer require hawksama/magento-2-performance-optimization
  • enable and apply database updates by running php bin/magento setup:upgrade*
  • compile the module by running php bin/magento setup:di:compile
  • Flush the cache by running php bin/magento cache:flush

How to upgrade

  • Update the module composer by running composer update hawksama/magento-2-performance-optimization
  • apply database updates by running php bin/magento setup:upgrade*
  • compile the module by running php bin/magento setup:di:compile
  • Flush the cache by running php bin/magento cache:flush

Configuration

Module enabled by default. CSS critical path recommended.

  • Enabled (hawksama_performanceoptimization/general/enabled)

  • Minify Html (hawksama_performanceoptimization/general/minify_html)

  • RequireJS CSS (hawksama_performanceoptimization/general/requirejs_css)

  • MoveJS to bottom Enabled (hawksama_performanceoptimization/movejs/enabled)

  • MoveJS to bottom Exclude Controllers (hawksama_performanceoptimization/movejs/home_page)

  • MoveJS to bottom Exclude Paths (hawksama_performanceoptimization/movejs/controller)

  • Stores > Settings > Configuration > HAWKSAMA -> Performance Optimization

Activate CSS critical path

  • To enable it run php bin/magento config:set 'dev/css/use_css_critical_path' 1;

Specifications

  • Helper

    • Hawksama\PerformanceOptimization\Helper\Data
  • Plugin

    • beforeSendResponse - Magento\Framework\App\Response\Http > Hawksama\PerformanceOptimization\Plugin\Frontend\Magento\Framework\App\Response\Http
  • Observer

    • controller_front_send_response_before > Hawksama\PerformanceOptimization\Observer\Frontend\Controller\FrontSendResponseBefore
  • Block

    • Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray

Support