Giter Club home page Giter Club logo

laravel-html-minify's Introduction

Laravel HTML Minify

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

laravel-html-minify's People

Contributors

fitztrev avatar bitdeli-chef avatar thomaswelton avatar blazeworx avatar

Watchers

James Cloos avatar Andrei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.