Skip to main content

Configuring the extension

A few steps to quickly set up and optimize your Magento 2 store performance.

The Google PageSpeed Optimizer extension helps improve your site’s loading speed and Core Web Vitals score by optimizing JavaScript, CSS, HTML, and images.
Follow the steps below to configure the extension for maximum efficiency.


Step 1: Access the extension settings

Go to Stores > Configuration > Mirasvit Extensions > Google PageSpeed Optimizer

Here you’ll find all global settings grouped into intuitive sections:

Each section contains detailed controls for optimizing specific resource types.


Step 2: Enable core optimizations

Start with enabling the main optimization features:

  • Enable JavaScript Optimization
  • Enable CSS Optimization
  • Enable HTML Optimization
  • Enable Image Optimization

Click Save Config, then flush cache to apply changes.

We recommend enabling one section at a time and testing your site performance after each change.


Step 3: Configure image optimization

The extension uses a set of tools to optimize or convert images. All images are processed in the pub/media folder.

To check your environment status, run the following command:

bin/magento mirasvit:optimize-image:validate
Note

Suppose you receive a message about certain libraries that have not yet been installed. In that case, you can install them by running the command: sudo yum install <library_name> (Centos) or sudo apt-get install <library_name> (Ubuntu). They can be installed all together, for example, by running: sudo apt-get install jpegoptim optipng gifsicle webp imagemagick After this, you can wait for a while (until optimization has been completed by cron) or else run commands for the optimization: bin/magento mirasvit:optimize-image:optimize - run images optimization process bin/magento mirasvit:optimize-image:webp - create a copy of the images in .webp format The images optimization process doesn't require any additional commands in the crontab on your server. It runs on Magento's default crontab. Should you receive a message stating that a package is not available at any point during the package installation, you can upload the relevant package directly to the server and perform a manual installation as a workaround. Please refer to these articles for manual installation instructions:

Go to image optimization settings to enable and fine-tune image handling.

  1. Enable use WebP images
    Converts images to the modern, lightweight WebP format for faster loading.

  2. Adjust image quality level

  3. Choose image optimization strategy

  4. Enable lazy-load to delay image loading until visible on screen.


Step 4: Run pre-fly check for JavaScript

Under JavaScript Optimization, click Run Pre-fly Checking to verify that all JS resources can be safely optimized and bundled without errors.

If the test passes, enable:

  • Minify JavaScript
  • Move JavaScript to Page Bottom

These settings significantly reduce render-blocking scripts and improve your Lighthouse score.


Step 5: Test and verify optimization

After configuration, check your store’s performance using Google PageSpeed Insights or Lighthouse.

  • Test both desktop and mobile versions.
  • Gradually enable or disable settings based on compatibility and score improvements.
  • Make sure cron jobs are configured to process image optimization regularly.

See how to ensure images are optimized for more details.


Generate responsive images (optional)

You can generate responsive image versions for desktop and mobile screens.

  1. Go to Responsive Images settings.
  2. Add patterns with desired image widths for desktop and mobile.
  3. Click Save Config, then Generate.
  4. After generation, flush cache.

Learn more in how to generate responsive images.


Exclude pages or files from optimization (optional)

In some cases, you might need to skip optimization for specific pages or scripts.

  • Use Do not use JS bundles on pages to exclude certain URLs or controller actions.
  • Use Do not minify files to exclude specific JS or CSS files.

See more in how to skip optimization on specific pages.


Once configured, your store will load faster, reduce server load, and perform better in Google’s PageSpeed Insight.

See the full guide in how to improve your PageSpeed score.