2017 © Pedro Peláez
 

library laravel-page-speed

Laravel Page Speed

image

renatomarinho/laravel-page-speed

Laravel Page Speed

  • Sunday, March 18, 2018
  • by renatomarinho
  • Repository
  • 76 Watchers
  • 1155 Stars
  • 61,218 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 106 Forks
  • 18 Open issues
  • 24 Versions
  • 27 % Grown

The README.md

Laravel Page Speed logo , (*1)

Build Status Latest Stable Version Total Downloads License , (*2)

Laravel Page Speed

Simple package to minify HTML output on demand which results in a 35%+ optimization. Laravel Page Speed was created by Renato Marinho, and currently maintained by João Roberto P. Borges, Lucas Mesquita Borges and Renato Marinho., (*3)

Installation

Requires: - PHP 7.2.5+ - Laravel 6.0+, (*4)

You can install the package via composer:, (*5)

composer require renatomarinho/laravel-page-speed

This package supports Laravel Package Discovery., (*6)

Publish configuration file

php artisan vendor:publish --provider="RenatoMarinho\LaravelPageSpeed\ServiceProvider", (*7)

Do not forget to register middlewares

Next, the \RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class and other middleware must be registered in the kernel, for example:, (*8)

//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, // Note: This middleware invokes "RemoveComments::class" before it runs.
    \RenatoMarinho\LaravelPageSpeed\Middleware\DeferJavascript::class,
]

Middlewares Details

\RenatoMarinho\LaravelPageSpeed\Middleware\RemoveComments::class

The RemoveComments::class filter eliminates HTML, JS and CSS comments. The filter reduces the transfer size of HTML files by removing the comments. Depending on the HTML file, this filter can significantly reduce the number of bytes transmitted on the network., (*9)

\RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class

The CollapseWhitespace::class filter reduces bytes transmitted in an HTML file by removing unnecessary whitespace. This middleware invoke RemoveComments::class filter before executation., (*10)

Note: Do not register the "RemoveComments::class" filter with it. Because it will be called automatically by "CollapseWhitespace::class", (*11)

Before

Before of Laravel Page Speed, (*12)

After

After of Laravel Page Speed, (*13)

\RenatoMarinho\LaravelPageSpeed\Middleware\RemoveQuotes::class

The RemoveQuotes::class filter eliminates unnecessary quotation marks from HTML attributes. While required by the various HTML specifications, browsers permit their omission when the value of an attribute is composed of a certain subset of characters (alphanumerics and some punctuation characters)., (*14)

Quote removal produces a modest savings in byte count on most pages., (*15)

\RenatoMarinho\LaravelPageSpeed\Middleware\ElideAttributes::class

The ElideAttributes::class filter reduces the transfer size of HTML files by removing attributes from tags when the specified value is equal to the default value for that attribute. This can save a modest number of bytes, and may make the document more compressible by canonicalizing the affected tags., (*16)

\RenatoMarinho\LaravelPageSpeed\Middleware\InsertDNSPrefetch::class

The InsertDNSPrefetch::class filter Injects tags in the HEAD to enable the browser to do DNS prefetching., (*17)

DNS resolution time varies from <1ms for locally cached results, to hundreds of milliseconds due to the cascading nature of DNS. This can contribute significantly towards total page load time. This filter reduces DNS lookup time by providing hints to the browser at the beginning of the HTML, which allows the browser to pre-resolve DNS for resources on the page., (*18)

### ⚠️ \RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class,, (*19)

The TrimUrls::class filter trims URLs by resolving them by making them relative to the base URL for the page., (*20)

Warning: 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., (*21)

\RenatoMarinho\LaravelPageSpeed\Middleware\InlineCss::class

The InlineCss::class filter transforms the inline "style" attribute of tags into classes by moving the CSS to the header., (*22)

\RenatoMarinho\LaravelPageSpeed\Middleware\DeferJavascript::class

Defers the execution of javascript in the HTML., (*23)

If necessary cancel deferring in some script, use data-pagespeed-no-defer as script attribute to cancel deferring., (*24)


Configuration

After installing package, you may need to configure some options., (*25)

Disable Service

You would probably like to set up the local environment to get a readable output., (*26)

//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

You would probably like to configure the package to skip some routes., (*27)

//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..., (*28)

Notice: This package skip automatically 'binary' and 'streamed' responses. See File Downloads., (*29)

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details., (*30)

Contributors

Inspiration

Mod Page Speed (https://www.modpagespeed.com/)

License

The MIT License (MIT). Please see License File for more information., (*31)

The Versions

18/03 2018

dev-master

9999999-dev

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

11/02 2018

1.8.7

1.8.7.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

02/12 2017

1.8.6

1.8.6.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

12/11 2017

1.8.5

1.8.5.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

03/11 2017

1.8.4

1.8.4.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

20/10 2017

1.8.3

1.8.3.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

20/10 2017

1.8.2

1.8.2.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

18/10 2017

1.8.1

1.8.1.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

16/10 2017

1.8.0

1.8.0.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

14/10 2017

1.7.0

1.7.0.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

13/10 2017

1.6.0

1.6.0.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

07/10 2017

1.5.5

1.5.5.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

02/10 2017

1.5.4

1.5.4.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

02/10 2017

1.5.3

1.5.3.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

01/10 2017

1.5.2

1.5.2.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

28/09 2017

1.5.1

1.5.1.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

24/09 2017

1.5.0

1.5.0.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

24/09 2017

1.4.0

1.4.0.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

24/09 2017

1.3.0

1.3.0.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

23/09 2017

1.2.0

1.2.0.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

14/09 2017

1.1.0

1.1.0.0

Laravel Page Speed

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html minify page speed optmize

12/09 2017

1.0.1

1.0.1.0

Laravel Blade Minify HTML

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html blade minify

10/09 2017

dev-add-license-1

dev-add-license-1

Laravel Blade Minify HTML

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html blade minify

10/09 2017

1.0.0

1.0.0.0

Laravel Blade Minify HTML

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel html blade minify