# etechflow/module-page-speed-optimizer

> Magento 2 Page Speed Optimizer Pro — Google PageSpeed Insights diagnostic, WebP image conversion + picture blocks + native lazy-load, HTML minification, JS defer-to-footer, Defer Fonts Loading with exclusion list, Server Push / resource preload hints, Back/Forward Cache compatibility. Full Amasty PSO Pro feature parity at lower price.

`composer require etechflow/module-page-speed-optimizer`

Canonical URL: https://packagento.com/etechflow/module-page-speed-optimizer

## At a glance

- **Vendor**: etechflow (https://packagento.com/etechflow.md)
- **Latest version**: 2.5.5 — released 2026-06-22
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/etechflow/module-page-speed-optimizer and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require etechflow/module-page-speed-optimizer:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Magento 2 Page Speed Optimizer Pro — Google PageSpeed Insights diagnostic, WebP image conversion + picture blocks + native lazy-load, HTML minification, JS defer-to-footer, Defer Fonts Loading with exclusion list, Server Push / resource preload hints, Back/Forward Cache compatibility. Full Amasty PSO Pro feature parity at lower price.

## README

Magento 2 module that integrates with Google PageSpeed Insights — run real performance diagnostics from the admin, see Lighthouse lab data + real-user CrUX field data side-by-side, and get inline mappings from Google's recommendations to the ETechFlow setting that fixes each one.

Code optimization (CSS/JS/HTML minification, defer fonts, prioritize resource loading) is in development for v1.1+. v1.0 ships the visible-value feature first.

### Install

```bash
composer require etechflow/module-page-speed-optimizer:^1.0
bin/magento module:enable ETechFlow_PageSpeedOptimizer
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
## Restart php-fpm to clear OPcache (mandatory on prod with opcache.validate_timestamps=0)
```

### Set up the Google API key (~3 min, one-time)

1. https://console.cloud.google.com/apis/credentials → **Create Credentials → API Key** (free)
2. Enable **PageSpeed Insights API** on the project (free, 25,000 requests/day)
3. Paste the key into **Stores → Configuration → eTechFlow → Page Speed Optimizer → Google PageSpeed Insights → API Key**

Without a key it still works, but you'll hit Google's per-IP rate limit (~1 request/second).

### Activate the licence

```bash
php tools/generate-license.php --module=page-speed-optimizer --host=<your-domain>
```

Paste the key into **Configuration → eTechFlow → Page Speed Optimizer → License Key** (or use the **Bundle License Key** if you're an ETechFlow suite customer).

### Verify

```bash
bin/magento etechflow:pso:verify
```

Ten PASS lines means you're good to go.

### Run your first diagnostic

```bash
bin/magento etechflow:pso:diagnose --url=https://your-store.com/ --strategy=mobile
```

Or via the admin: **Stores → Settings → Page Speed Diagnose** → click **Run diagnostic**.

### Configuration

`Stores → Configuration → eTechFlow → Page Speed Optimizer`:

- **License Key** — per-module key (or use Bundle License Key for the suite)
- **Module Enabled** — toggle the whole module
- **Google PageSpeed Insights API Key** — your Google Cloud API key
- **Default Strategy** — mobile (Google's mobile-first indexing default) or desktop
- **API Timeout** — default 90s (PSI typically takes 15-45s per page)

### Compatibility

- Magento Open Source 2.4.4 – 2.4.8
- Adobe Commerce 2.4.4 – 2.4.8
- PHP 8.1 / 8.2 / 8.3 / 8.4
- Hyvä Theme + Hyvä Checkout — admin-only module, theme-agnostic

### Support

info@etechflow.com — include your license key + Magento version when reporting issues.

## Changelog

All notable changes to this module. Adheres to [Semantic Versioning](https://semver.org/).

---

### [2.4.0] — 2026-06-04 — Portal licensing (SP-XXXX + Stripe) + image-optimization & diagnose fixes

#### Added

- **SP-XXXX portal licensing** — `Model/LicenseValidator.php` rewritten to the hybrid model (HMAC per-module/bundle key + portal-validated subscription with two-factor domain + server-IP binding, IP-block auto-management, 48h grace, result caching). Preserves the existing HMAC `MODULE_ID`/`SECRET_FRAGMENTS`/bundle key.
- **In-admin Stripe checkout + gate page** — `Controller/Adminhtml/License/{Gate,Checkout,Activated}.php` + dark gate with Weekly $12 / Monthly $39 / Yearly $390 cards; pays via Stripe and auto-saves the issued key. New `payment` config group (Stripe keys) + license fields (issued_key, portal_url, bundle key). All four admin pages (Diagnose, Trends, Image Optimization Log, Cron Tasks) gate to the license page until activated.

#### Fixed

- **Diagnose desktop timeouts** — added a 2-attempt retry in `Model/Psi/PsiClient.php` (full first attempt + short cached-result retry) so Google PSI's occasional desktop stalls self-recover.
- **Image Optimization Log page crashed (cascade of shipped naming bugs)**: `Model/Source/OptimizationStatusOptions.php` declared `class StatusOptions` → renamed; layout block path `…\Log\SavingsSummary` → `…\OptimizationLog\SavingsSummary`; template `::log/…` → `::optimizationlog/…`; grid dataProvider `ETechFlowIoLogGridDataProvider` → `ETechFlowPsoOptimizationLogGridDataProvider`; added the missing `SearchResult` grid-collection virtualType in di.xml.
- **Bulk WebP conversion silently failed every image** — `Model/Image/WebpGenerator.php` was missing `use …\Model\OptimizationLog;`, so `OptimizationLog::STATUS_OK` resolved to a non-existent class and the log insert threw. `etechflow:pso:optimize-images` now converts + logs correctly (~50% size reduction with Imagick/GD).
- **PSI API key field** changed from `obscure` (encrypted) to plain `text` to match the non-decrypting getter (a Google PSI key is non-sensitive).
- **Admin menu** no longer re-declares the shared `eTechFlow::root` node (avoids a duplicate-menu crash when other eTechFlow modules are installed).

### [2.3.1] — 2026-05-30 — First Packagist release: menu reorganisation + always-a-patch discipline

First tagged release on Packagist. Prior versions existed in the internal
working repo only.

#### Changed

- **Admin menu reorganised** under the shared eTechFlow top-level sidebar
  group, matching the convention adopted across all ETechFlow modules
  (Amasty-style consolidated menu). Previously a standalone top-level
  entry; now nested under eTechFlow → Page Speed Optimizer for visual
  consistency when multiple ETechFlow modules are installed.

#### Added

- **`Setup/Patch/Data/V231ReleaseMarker.php`** — no-op release marker
  patch. Establishes the always-a-patch discipline previously adopted in
  NDE v1.7.1, BED v1.2.2, and ISP v2.0.0. Every release ships at least
  one patch so `setup:upgrade` always has something to register in
  `patch_list` — surfacing FS / permissions / DI errors during the patch
  phase (which retries cleanly) instead of at the end of the upgrade
  (which doesn't). v2.3.1 is the first tagged release, hence the marker.

#### Migration

```bash
composer require etechflow/module-page-speed-optimizer:^2.3.1
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
```

Pre-flight check after upgrade:
```sql
SELECT module, schema_version, data_version FROM setup_module
WHERE module='ETechFlow_PageSpeedOptimizer';
```
Both columns should read `2.3.1`. If `data_version` is stale, re-run
`setup:upgrade` — do NOT flush cache yet.

---

### [2.3.0] — 2026-05-21 — Smart optimization by viewed pages — 14/14 Amasty Pro features matched ✅

_(Changelog truncated for .md surface. Full history on https://packagento.com/etechflow/module-page-speed-optimizer.)_

## Recent Versions

| Version | Released |
|---|---|
| 2.5.5 | 2026-06-22 |
| 2.5.4 | 2026-06-22 |
| 2.5.0 | 2026-06-06 |
| 2.4.0 | 2026-06-04 |
| 2.3.1 | 2026-05-30 |
| 2.3.0 | 2026-05-21 |
| 2.2.0 | 2026-05-21 |
| 2.1.0 | 2026-05-21 |
| 2.0.0 | 2026-05-21 |
| 1.1.0 | 2026-05-21 |

Showing 10 of 11 versions. Full release history on https://packagento.com/etechflow/module-page-speed-optimizer.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| magento/framework | ^103.0\|\|^104.0 |
| magento/module-backend | ^102.0\|\|^103.0 |
| magento/module-catalog | ^104.0\|\|^105.0 |
| magento/module-config | ^101.2\|\|^102.0 |
| magento/module-store | ^101.1\|\|^102.0 |
| magento/module-ui | ^101.2\|\|^102.0 |
| php | ~8.1.0\|\|~8.2.0\|\|~8.3.0\|\|~8.4.0 |

### Suggest

| Package | Constraint |
|---|---|
| etechflow/module-back-in-stock-notification | Bundle key activates this module too. |
| etechflow/module-image-optimizer | Lighter sibling with image-optimization only. PSO Pro supersedes it on full-feature stores. |
| etechflow/module-next-day-eligibility | Bundle key activates this module too. |

## Quality

Latest release (2.5.5) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | not tested |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 535 | 85 errors, 450 warnings (ruleset: Magento2) — 212 auto-fixable with phpcbf |
| PHPMD | Warning | 119 | 119 rule violations (ErrorControlOperator:42, MissingImport:41, NPathComplexity:13, CyclomaticComplexity:9, UnusedFormalParameter:7) |
| Cpd | Warning | 1 | 1 duplicated chunk spanning 29 total lines (min-lines=5, min-tokens=70) |
| Composer validate | Info | 1 | valid; 1 advisory note (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 30 | 30 | – | – |
| 2.4.8 | – | 30 | 30 | – |
| 2.4.9 | – | – | 30 | N/A |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["etechflow/module-page-speed-optimizer"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

etechflow is a Magento 2 vendor on Packagento. See https://packagento.com/etechflow.md for their full catalogue.

