PHPackages                             chenjia404/laravel-page-speed - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. chenjia404/laravel-page-speed

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

chenjia404/laravel-page-speed
=============================

Laravel Page Speed

v2.1.2(1y ago)110MITPHPPHP ^8.0CI passing

Since Dec 16Pushed 2mo agoCompare

[ Source](https://github.com/chenjia404/laravel-page-speed)[ Packagist](https://packagist.org/packages/chenjia404/laravel-page-speed)[ RSS](/packages/chenjia404-laravel-page-speed/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

 [![Laravel Page Speed](https://raw.githubusercontent.com/vinkius-labs/laravel-page-speed/master/art/logo.png)](https://raw.githubusercontent.com/vinkius-labs/laravel-page-speed/master/art/logo.png)

 [![Latest Version](https://camo.githubusercontent.com/3edbfd4954b27e6324c67b23ffa4446ad84815672b8a0030ab32e84548e8f706/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76696e6b6975732d6c6162732f6c61726176656c2d706167652d73706565643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vinkius-labs/laravel-page-speed) [![Total Downloads](https://camo.githubusercontent.com/40917b0dff028d4f18f311e95f8b7e123bdbb3e48bd4a3c31026547472ed2613/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72656e61746f6d6172696e686f2f6c61726176656c2d706167652d73706565643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/renatomarinho/laravel-page-speed) [![Daily Downloads](https://camo.githubusercontent.com/679efffe62c47f6c2a30a5c6923054a490e186a599832e5e211cafafa49ef233/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64642f76696e6b6975732d6c6162732f6c61726176656c2d706167652d73706565643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vinkius-labs/laravel-page-speed) [![License](https://camo.githubusercontent.com/49cc3dc4cea467e873856beb6d9958a61279b9a725613ed544c238f8b6a87d87/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f76696e6b6975732d6c6162732f6c61726176656c2d706167652d73706565643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vinkius-labs/laravel-page-speed) [![GitHub Stars](https://camo.githubusercontent.com/1f3325db468c47497449d41af9fad136ceb34773bc960f400fdd97bf3988c7f8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f76696e6b6975732d6c6162732f6c61726176656c2d706167652d73706565643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vinkius-labs/laravel-page-speed) [![PHP Version](https://camo.githubusercontent.com/32a698dca37aef3a6f4a0949201104d34949620db4b804ce37dc8cb90852ce18/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f76696e6b6975732d6c6162732f6c61726176656c2d706167652d73706565643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vinkius-labs/laravel-page-speed)

Laravel Page Speed
==================

[](#laravel-page-speed)

Laravel Page Speed delivers an end-to-end optimization pipeline for Blade-rendered pages and REST APIs with measurable gains in latency, bandwidth, and resiliency.

Table of Contents
-----------------

[](#table-of-contents)

- [Overview](#overview)
- [Optimization Pipelines](#optimization-pipelines)
- [Quick Integration](#quick-integration)
- [Measured Impact](#measured-impact)
- [Observability and Resilience](#observability-and-resilience)
- [Documentation Suite](#documentation-suite)
- [Contributing and Support](#contributing-and-support)

Overview
--------

[](#overview)

- **Dual scope**: optimizes rendered HTML and JSON/XML payloads without modifying your business payloads.
- **Composable stack**: enable only the middleware you need through `config/laravel-page-speed.php`.
- **Store-agnostic**: works with Redis, Memcached, DynamoDB (via cache tags), file, or array drivers across Laravel 10–13.
- **Built for observability**: exposes latency, memory usage, cache hits, and circuit status via standard HTTP headers.

Optimization Pipelines
----------------------

[](#optimization-pipelines)

### Web (HTML/Blade)

[](#web-htmlblade)

- Structured HTML minification and comment stripping that stay compatible with Bootstrap, Tailwind, and Livewire.
- Targeted critical CSS inlining to reduce render-blocking round trips.
- Script deferral and DNS prefetching that maintain execution order through `data-ps-*` guards.

### APIs (REST/JSON)

[](#apis-restjson)

- Adaptive compression (Brotli first, Gzip fallback) with configurable size thresholds to avoid overhead on small payloads.
- Response caching with method-aware invalidation, dynamic tag derivation per path segment, and hit-rate metrics.
- Pre-hardened security headers (HSTS, CSP, Permissions-Policy) and an automatic circuit breaker with customizable fallbacks.
- Lightweight health check middleware designed for Kubernetes probes and service orchestrators.

Quick Integration
-----------------

[](#quick-integration)

### Web Middleware

[](#web-middleware)

Choose the registration pattern that matches your Laravel install:

**Laravel 10.x (`app/Http/Kernel.php`)**

Append the middleware inside the `web` group so the order stays deterministic:

```
protected $middlewareGroups = [
    'web' => [
        // ... existing middleware
        \VinkiusLabs\LaravelPageSpeed\Middleware\InlineCss::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\ElideAttributes::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\InsertDNSPrefetch::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\CollapseWhitespace::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\DeferJavascript::class,
    ],
];
```

**Laravel 11.x, 12.x and 13.x (`bootstrap/app.php`)**

Use the middleware configurator introduced in Laravel 11. Extend the existing `->withMiddleware` closure:

```
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: __DIR__.'/../')
    // ... existing configuration
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->appendToGroup('web', [
            \VinkiusLabs\LaravelPageSpeed\Middleware\InlineCss::class,
            \VinkiusLabs\LaravelPageSpeed\Middleware\ElideAttributes::class,
            \VinkiusLabs\LaravelPageSpeed\Middleware\InsertDNSPrefetch::class,
            \VinkiusLabs\LaravelPageSpeed\Middleware\CollapseWhitespace::class,
            \VinkiusLabs\LaravelPageSpeed\Middleware\DeferJavascript::class,
        ]);

        // keep other group definitions (api, broadcast, etc.) here
    })
    ->create();
```

### API Middleware

[](#api-middleware)

Attach only the middleware that fits your API architecture.

**Laravel 10.x (`app/Http/Kernel.php`)**

```
protected $middlewareGroups = [
    'api' => [
        // ... existing middleware
        \VinkiusLabs\LaravelPageSpeed\Middleware\ApiSecurityHeaders::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\ApiResponseCache::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\ApiETag::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\ApiResponseCompression::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\ApiPerformanceHeaders::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\ApiCircuitBreaker::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\ApiHealthCheck::class,
    ],
];
```

**Laravel 11.x, 12.x and 13.x (`bootstrap/app.php`)**

Inside the same `->withMiddleware` closure from the Web section, append the API stack:

```
$middleware->appendToGroup('api', [
    \VinkiusLabs\LaravelPageSpeed\Middleware\ApiSecurityHeaders::class,
    \VinkiusLabs\LaravelPageSpeed\Middleware\ApiResponseCache::class,
    \VinkiusLabs\LaravelPageSpeed\Middleware\ApiETag::class,
    \VinkiusLabs\LaravelPageSpeed\Middleware\ApiResponseCompression::class,
    \VinkiusLabs\LaravelPageSpeed\Middleware\ApiPerformanceHeaders::class,
    \VinkiusLabs\LaravelPageSpeed\Middleware\ApiCircuitBreaker::class,
    \VinkiusLabs\LaravelPageSpeed\Middleware\ApiHealthCheck::class,
]);
```

### Publish assets and baseline environment variables

[](#publish-assets-and-baseline-environment-variables)

```
composer require vinkius-labs/laravel-page-speed
php artisan vendor:publish --provider="VinkiusLabs\\LaravelPageSpeed\\ServiceProvider"
```

Recommended baseline for cached APIs:

```
LARAVEL_PAGE_SPEED_ENABLE=true
API_CACHE_ENABLED=true
API_CACHE_DRIVER=redis
API_CACHE_TTL=300
API_CACHE_DYNAMIC_TAGS=true
```

Measured Impact
---------------

[](#measured-impact)

MetricBeforeAfter (cache hit)DeltaPage Size (Blade)245 KB159 KB-35%First Paint1.8 s1.2 s-33%API Payload15.2 KB2.8 KB-82%Average API Latency450 ms2 ms-99.6%SQL Queries (100-item list)350-100%Monthly Bandwidth (estimate)15 TB3 TB-80%Reference scenario: 1M requests/day with a 65% cache hit rate.

Observability and Resilience
----------------------------

[](#observability-and-resilience)

- **Performance headers**: `X-Response-Time`, `X-Memory-Usage`, `X-Cache-Status`, `X-Circuit-Breaker-State` ready for ingestion by Datadog, New Relic, or Prometheus scrapers.
- **Configurable circuit breaker**: customize failure thresholds, timeout, and scope (route, endpoint, or path) via configuration.
- **Adaptive health check**: aggregates database, cache, disk, and queue probes with optional 10-second result caching.
- **Debug-aware skipping**: curated `skip` patterns avoid instrumenting Debugbar, Telescope, Horizon, or custom diagnostic routes.

Documentation Suite
-------------------

[](#documentation-suite)

- [Documentation Hub](docs/README.md)
- [Web Optimization](docs/WEB-OPTIMIZATION.md)
- [API Optimization](docs/API-OPTIMIZATION.md)
- [Cache Architecture](docs/API-CACHE.md)
- [Configuration Reference](docs/CONFIGURATION.md)
- [Scenario Playbooks](docs/API-EXAMPLES.md)
- [Executive Summary](docs/PACKAGE-SUMMARY.md)

Contributing and Support
------------------------

[](#contributing-and-support)

- Review [CONTRIBUTING.md](CONTRIBUTING.md) before opening pull requests.
- Run `composer test` (or `docker compose exec app vendor/bin/phpunit`) prior to submitting changes.
- File issues and start discussions via [GitHub Issues](../../issues) and [Discussions](../../discussions).
- Distributed under the [MIT license](LICENSE.md).

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance66

Regular maintenance activity

Popularity7

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

513d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4389c628f53b9a3ca6f0c69f6e4d2901debd9dbe1fb3ca699ac9b290e257952?d=identicon)[chenjia404](/maintainers/chenjia404)

---

Top Contributors

[![joaorobertopb](https://avatars.githubusercontent.com/u/6556083?v=4)](https://github.com/joaorobertopb "joaorobertopb (63 commits)")[![renatomarinho](https://avatars.githubusercontent.com/u/26571?v=4)](https://github.com/renatomarinho "renatomarinho (46 commits)")[![lucasMesquitaBorges](https://avatars.githubusercontent.com/u/42281497?v=4)](https://github.com/lucasMesquitaBorges "lucasMesquitaBorges (19 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (5 commits)")[![stakahashi](https://avatars.githubusercontent.com/u/3667416?v=4)](https://github.com/stakahashi "stakahashi (5 commits)")[![tswestendorp](https://avatars.githubusercontent.com/u/1061961?v=4)](https://github.com/tswestendorp "tswestendorp (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![kenzouno1](https://avatars.githubusercontent.com/u/1946802?v=4)](https://github.com/kenzouno1 "kenzouno1 (2 commits)")[![saifulwebid](https://avatars.githubusercontent.com/u/1644410?v=4)](https://github.com/saifulwebid "saifulwebid (2 commits)")[![patrickbrouwers](https://avatars.githubusercontent.com/u/7728097?v=4)](https://github.com/patrickbrouwers "patrickbrouwers (1 commits)")[![percymamedy](https://avatars.githubusercontent.com/u/11259669?v=4)](https://github.com/percymamedy "percymamedy (1 commits)")[![caneco](https://avatars.githubusercontent.com/u/502041?v=4)](https://github.com/caneco "caneco (1 commits)")[![tvbeek](https://avatars.githubusercontent.com/u/2026498?v=4)](https://github.com/tvbeek "tvbeek (1 commits)")[![swilla](https://avatars.githubusercontent.com/u/304159?v=4)](https://github.com/swilla "swilla (1 commits)")[![andysnell](https://avatars.githubusercontent.com/u/7006523?v=4)](https://github.com/andysnell "andysnell (1 commits)")[![f-liva](https://avatars.githubusercontent.com/u/346224?v=4)](https://github.com/f-liva "f-liva (1 commits)")[![JapSeyz](https://avatars.githubusercontent.com/u/2234034?v=4)](https://github.com/JapSeyz "JapSeyz (1 commits)")[![gofish543](https://avatars.githubusercontent.com/u/10394554?v=4)](https://github.com/gofish543 "gofish543 (1 commits)")[![lakuapik](https://avatars.githubusercontent.com/u/20186786?v=4)](https://github.com/lakuapik "lakuapik (1 commits)")

---

Tags

laravelhtmlminifypage-speedoptimize

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/chenjia404-laravel-page-speed/health.svg)

```
[![Health](https://phpackages.com/badges/chenjia404-laravel-page-speed/health.svg)](https://phpackages.com/packages/chenjia404-laravel-page-speed)
```

###  Alternatives

[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k5.4k1](/packages/vinkius-labs-laravel-page-speed)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M10](/packages/renatomarinho-laravel-page-speed)[unisharp/laravel-ckeditor

JavaScript WYSIWYG web text editor (for laravel).

377762.3k5](/packages/unisharp-laravel-ckeditor)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
