Skip to main content

Command line interface

The Google Page Speed Optimizer extension provides several CLI commands to test page speed, optimize images, and manage WebP conversion. These commands are especially useful for bulk operations, maintenance tasks, or integrating into deployment scripts.

Available commands

1. Run a PageSpeed test

bin/magento mirasvit:optimize-insight:pagespeed https://example.com/

What it does: performs a Google PageSpeed Insights analysis for the specified URL and returns performance metrics. Useful for testing whether your optimizations are effective or diagnosing speed issues.


2. Validate image optimization environment

bin/magento mirasvit:optimize-image:validate

What it does: checks if your server environment meets the necessary requirements for image optimization (e.g. presence of required libraries or binaries). Use this after deployment or server changes to confirm image tools will work properly.


3. Run image optimization/WebP conversion

bin/magento mirasvit:optimize-image:optimize [--image] [--webp]

What it does: optimizes your store’s existing images and optionally generates WebP versions of them.

  • --image runs standard image compression/optimization according to your configured quality settings.
  • --webp generates WebP-format versions based on your WebP compression configuration. If you run the command without any flags, it assumes both image optimization and WebP generation (if allowed by configuration). This same process also runs automatically via cron, so this CLI is primarily useful for manual or bulk triggers.

4. Restore original images

bin/magento mirasvit:optimize-image:restore

What it does: reverts all optimized and WebP images back to their original versions, removing the converted/optimized files. Use this if you need to roll back image optimizations for testing or troubleshooting.