Laravel Page Speed - 压缩HTML文件

简介

压缩Laravel输出的HTML,大约有35%以上的优化空间。

使用

安装

composer require renatomarinho/laravel-page-speed

发布配置文件

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

增加全局中间件

//app/Http/Kernel.php

protected $middleware = [
    ...
    \RenatoMarinho\LaravelPageSpeed\Middleware\InlineCss::class,
    \RenatoMarinho\LaravelPageSpeed\Middleware\ElideAttributes::class,
    \RenatoMarinho\LaravelPageSpeed\Middleware\InsertDNSPrefetch::class,
    \RenatoMarinho\LaravelPageSpeed\Middleware\RemoveComments::class,
    \RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class,
    \RenatoMarinho\LaravelPageSpeed\Middleware\RemoveQuotes::class,
    \RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class,
]