PHPackages                             arafatkhairul/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. arafatkhairul/laravel-page-speed

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

arafatkhairul/laravel-page-speed
================================

Laravel Page Speed

012PHP

Since Aug 9Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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

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

[](#laravel-page-speed)

### Simple package to minify HTML output on demand which results in a 60%+ optimization.

[](#simple-package-to-minify-html-output-on-demand-which-results-in-a-60-optimization)

Installation
------------

[](#installation)

You can install the package via composer:

```
$ composer require arafatkhairul/laravel-page-speed
```

### Laravel 5.5 and up

[](#laravel-55-and-up)

Laravel 5.5 and up uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

### Laravel 5.4 or 5.3

[](#laravel-54-or-53)

Add the Service Provider to the providers array in **config/app.php**:

`ArafatIslamKhairul\LaravelPageSpeed\ServiceProvider::class`

*This is required for publishing the configuration file:*

### Publish configuration file

[](#publish-configuration-file)

`php artisan vendor:publish --provider="ArafatIslamKhairul\LaravelPageSpeed\ServiceProvider"`

Do not forget to register middlewares
-------------------------------------

[](#do-not-forget-to-register-middlewares)

Next, the `\ArafatIslamKhairul\LaravelPageSpeed\Middleware\CollapseWhitespace::class` and other middleware must be registered in the kernel:

```
//app/Http/Kernel.php

->withMiddleware(function (Middleware $middleware) {
        $middleware->append(\ArafatIslamKhairul\LaravelPageSpeed\Middleware\InlineCss::class,);
        $middleware->append(\ArafatIslamKhairul\LaravelPageSpeed\Middleware\ElideAttributes::class,);
        $middleware->append(\ArafatIslamKhairul\LaravelPageSpeed\Middleware\InsertDNSPrefetch::class,);
        $middleware->append(\ArafatIslamKhairul\LaravelPageSpeed\Middleware\RemoveComments::class,);
        $middleware->append(\ArafatIslamKhairul\LaravelPageSpeed\Middleware\TrimUrls::class,);
        $middleware->append(\ArafatIslamKhairul\LaravelPageSpeed\Middleware\RemoveQuotes::class,);
        $middleware->append(\ArafatIslamKhairul\LaravelPageSpeed\Middleware\CollapseWhitespace::class,);
})
```

### Before

[](#before)

[![Before of Laravel Page Speed](https://camo.githubusercontent.com/b0141aa95fae5e66399f5d3dcdb20505e57860a0f80e7dd46b0c0e97ebcdb79b/68747470733a2f2f692e696d6775722e636f6d2f634e334d5759682e706e67)](https://camo.githubusercontent.com/b0141aa95fae5e66399f5d3dcdb20505e57860a0f80e7dd46b0c0e97ebcdb79b/68747470733a2f2f692e696d6775722e636f6d2f634e334d5759682e706e67)

### After

[](#after)

[![After of Laravel Page Speed](https://camo.githubusercontent.com/629e6e0b38a0f6798828033cdb48ec72ea6b22eb5af64a8c50f2f24800f132c1/68747470733a2f2f692e696d6775722e636f6d2f494b574b4c6b4c2e706e67)](https://camo.githubusercontent.com/629e6e0b38a0f6798828033cdb48ec72ea6b22eb5af64a8c50f2f24800f132c1/68747470733a2f2f692e696d6775722e636f6d2f494b574b4c6b4c2e706e67)

Roadmap : Filters
-----------------

[](#roadmap--filters)

  **Name** **Description** **Available**   inline\_css Inlines small external CSS files YES   elide\_attributes Removes unnecessary attributes in HTML tags YES   insert\_dns\_prefetch Injects tags in the HEAD to enable the browser to do DNS prefetching YES   remove\_quotes Removes unnecessary quotes in HTML tags YES   trim\_urls Removes unnecessary prefixes from URLs YES   collapse\_whitespace Removes unnecessary whitespace in HTML YES   remove\_comments Removes HTML comments YES   combine\_css Combines multiple CSS files into one NO   combine\_heads Combines multiple elements into one NO   combine\_javascript Combines multiple JavaScript files into one NO   dedup\_inlined\_images Replaces repeated inlined images with JavaScript that loads the data from the first instance of the image NO   defer\_javascript Defers the execution of javascript in the HTML NO   pedantic Adds default type attributes to script and style tags that are missing them NO   extend\_cache Improves cacheability NO   fallback\_rewrite\_css\_urls Rewrite URLs in CSS even if CSS is not parseable NO   flatten\_css\_imports Flattens @import rules in CSS by replacing the rule with the contents of the imported resource NO   hint\_preload\_subresources Inserts link: headers to preload CSS and JavaScript resources NO   inline\_google\_font\_css Inlines small font-loading CSS from Google Fonts API NO   inline\_import\_to\_link Inlines style tags comprising only CSS @imports by converting them to an equivalent link NO   inline\_javascript Inlines small external Javascript files NO   inline\_preview\_images Delays original images; serves inlined, low-quality placeholder images until originals are loaded NO   insert\_ga Inserts Google Analytics javascript snippet NO   lazyload\_images Loads images when they become visible in the client viewport NO   local\_storage\_cache Loads inlined CSS and image resources into HTML5 local storage whence the client fetches them subsequently rather than the server sending them again NO   make\_show\_ads\_async Converts synchronous Google AdSense tags to asynchronous format NO   make\_google\_analytics\_async Converts synchronous Google Analytics code to load asynchronously NO   move\_css\_above\_scripts Moves CSS above scripts NO   move\_css\_to\_head Moves CSS into the element NO   outline\_css Moves large inline 'style' tags into external files for cacheability NO   outline\_javascript Moves large inline 'script' tags into external files for cacheability NO   prioritize\_critical\_css Instruments the page, inlines its critical CSS at the top, and lazily loads the rest NO   resize\_mobile\_images Just like inline\_preview\_images, but uses smaller placeholder images for mobile browsers NO   resize\_rendered\_image\_dimensions Resize images to rendered dimensions NO   responsive\_images Serve responsive images using the srcset attribute NO   rewrite\_css Minifies CSS NO   rewrite\_images Rescales, and compresses images; inlines small ones NO   rewrite\_javascript Minifies Javascript NO   rewrite\_style\_attributes Rewrite the CSS in style attributes by applying the configured rewrite\_css filter to it NO   rewrite\_style\_attributes\_with\_url Rewrite the CSS in style attributes by applying the configured rewrite\_css filter to it, but only if the attribute contains the text 'url(' NO   sprite\_images Sprites images NO ---

Configuration
-------------

[](#configuration)

After installing package, you may need to configure some options.

### Disable Service

[](#disable-service)

You would probably like to set up the local environment to get a readable output.

```
//config/laravel-page-speed.php

//Set this field to false to disable the laravel page speed service.
'enable' => env('LARAVEL_PAGE_SPEED_ENABLE', true),
```

### Skip routes

[](#skip-routes)

You would probably like to configure the package to skip some routes.

```
//config/laravel-page-speed.php

//You can use * as wildcard.
'skip' => [
    '*.pdf', //Ignore all routes with final .pdf
    '*/downloads/*',//Ignore all routes that contain 'downloads'
    'assets/*', // Ignore all routes with the 'assets' prefix
];
```

By default this field comes configured with some options, so feel free to configure according to your needs...

> *Notice*: This package skip automatically 'binary' and 'streamed' responses. See [File Downloads](https://laravel.com/docs/6.0/responses#file-downloads).

Warning
-------

[](#warning)

**\\ArafatIslamKhairul\\LaravelPageSpeed\\Middleware\\TrimUrls::class** is considered **medium risk**. It can cause problems if it uses the wrong base URL. This can happen, for example, if you serve HTML that will be pasted verbatim into other HTML pages. If URLs are trimmed on the first page, they will be incorrect for the page they are inserted into. In this case, just disable the middleware.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Renato Marinho](https://github.com/ArafatIslamKhairul)
- [João Roberto P. Borges](https://github.com/joaorobertopb)
- [Caneco](https://twitter.com/caneco) (for the logo)
- [All Contributors](../../contributors)

Inspiration
-----------

[](#inspiration)

#### Mod Page Speed ()

[](#mod-page-speed-httpswwwmodpagespeedcom)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

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.

### Community

Maintainers

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

### Embed Badge

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

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

PHPackages © 2026

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