• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

fitztrev/laravel-html-minify: Minifies the HTML output of Laravel 4 applications

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

fitztrev/laravel-html-minify

开源软件地址(OpenSource Url):

https://github.com/fitztrev/laravel-html-minify

开源编程语言(OpenSource Language):

PHP 100.0%

开源软件介绍(OpenSource Introduction):

UPDATE for Laravel 5/5.1+

Read my preferred way of minifying HTML in Laravel 5/5.1+ apps here: Using Gulp to Minify Laravel Blade Templates


Laravel HTML Minify

For Laravel 4 - See here for L5+

Build Status Total Downloads

About

This package compresses the HTML output from your Laravel 4 application, seamlessly reducing the overall response size of your pages.

Other scripts that I've seen will compress the HTML output on-the-fly for each request. Instead, this package extends the Blade compiler to save the compiled template files to disk in their compressed state, reducing the overhead for each request.

Why?

Even with gzip enabled, there is still an improvement in the response size for HTML content-type documents.

Test Page w/o Gzip w/ Gzip w/ Gzip + Laravel HTML Minify
#1 8,039 bytes 1,944 bytes 1,836 bytes (5.6% improvement)
#2 377,867 bytes 5,247 bytes 4,314 bytes (17.8% improvement)

Installation

  1. Add "fitztrev/laravel-html-minify": "1.*" to composer.json.
  2. Run composer update
  3. Add Fitztrev\LaravelHtmlMinify\LaravelHtmlMinifyServiceProvider to the list of providers in app/config/app.php.
  4. Important: You won't see any changes until you edit your *.blade.php template files. Once Laravel detects a change, it will recompile them, which is when this package will go to work. To force all views to be recompiled, just run this command: find . -name "*.blade.php" -exec touch {} \;

Config

Optionally, you can choose to customize how the minifier functions for different environments. Publish the configuration file and edit accordingly.

$ php artisan config:publish fitztrev/laravel-html-minify

Options

  • enabled - boolean, default true

If you are using a javascript framework that conflicts with Blade's tags, you can change them.

  • blade.contentTags - array, default {{ and }}
  • blade.escapedContentTags - array, default {{{ and }}}

Skipping minification

To prevent the minification of a view file, add skipmin somewhere in the view.

{{-- skipmin --}}
<!-- skipmin -->



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap