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.
Requires:
You can install the package via composer:
composer require renatomarinho/laravel-page-speed
This package supports Laravel Package Discovery.
php artisan vendor:publish --provider="RenatoMarinho\LaravelPageSpeed\ServiceProvider"
Next, the \RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class
and other middleware must be registered in the kernel, for example:
//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,
]
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.
The CollapseWhitespace::class filter reduces bytes transmitted in an HTML file by removing unnecessary whitespace.This middleware invoke RemoveComments::class filter before executation.
Note: Do not register the "RemoveComments::class" filter with it. Because it will be called automatically by "CollapseWhitespace::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).
Quote removal produces a modest savings in byte count on most pages.
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.
The InsertDNSPrefetch::class filter Injects tags in the HEAD to enable the browser to do DNS prefetching.
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.
The TrimUrls::class filter trims URLs by resolving them by making them relative to the base URL for the page.
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.
The InlineCss::class filter transforms the inline "style" attribute of tags into classes by moving the CSS to the header.
Defers the execution of javascript in the HTML.
If necessary cancel deferring in some script, use
data-pagespeed-no-defer
as script attribute to cancel deferring.
After installing package, you may need to configure some options.
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),
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.
$ composer test
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.
laravel-page-speed 是一个在laravel中用于压缩html的扩展 https://github.com/renatomarinho/laravel-page-speed laravel-page-speed 的众多功能之一是会将所有style属性整理到class并输出到head标签中,如果最后输出的view中没有head标签,将会导致不生成对应的class 从而导致style属
kibana 喊话 介绍 (Introduction) Laravel is undoubtedly a very powerful framework with a lot of batteries included. One of the reasons I love laravel is the fact that it is built on events. Laravel无疑是一个非常强
在本章中,让我们研究如何在Drupal中创建Front Page 。 如果您的网站上有良好的内容并希望访问者首先看到该特定内容,那么该文章必须位于首页。 Drupal为此提供了解决方案。 以下是用于创建Drupal Front Page的简单步骤。 Step 1 - 单击Content ,如以下屏幕所示。 Step 2 - 屏幕上弹出文章和页面列表。 单击edit链接,如以下屏幕所示。 Step
Page Speed最 初是Google内部使用的改进网页设计的工具——它整合在Firefox的著名插件Firebug中。当用户运行Page Speed,可以立即获得如何改进网页载入速度的建议。Page Speed能自动为用户优化图像,提供可以发布在网页上的压缩图片,它也能识别JavaScript和CSS载入问题,帮助开发者减少浏览者等待网页展示 的时间。
Extends Composite A container representing a single page of a NavigationView widget. Import this type with “const {Page} = require('tabris');” Properties autoDispose Type: boolean, default: true Defin
@Page装饰器包含IONIC_DIRECTIVE中所有的组件和指令以及Angular中的CORS_DIRECTIVES和 FORM_DIRECTIVES。所以你只需要将你自定义的指令和组件依赖进去就好。 使用方法 @Page({ template: ` <ion-content> I am a page! </ion-content> ` }) class MyPa
注册小程序中的一个页面。接受一个 Object 类型参数,其指定页面的初始数据、生命周期回调、事件处理函数等。 1. 参数 属性 类型 默认值 必填 说明 data Object 页面的初始数据 onLoad function 生命周期回调—监听页面加载 onShow function 生命周期回调—监听页面显示 onReady function 生命周期回调—监听页面初次渲染完成 onHide
描述 (Description) page属性用于调用先前使用@page定义的页面选择器。 可能的值 (Possible Values) 《page selector》 - 使用@page的任何先前定义的页面选择器。 auto - 浏览器应根据其默认值格式化页面。 适用于 (Applies to) 所有块级元素。 例子 (Example) 这是一个例子 - <style type="text/cs