├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── composer.json
├── phpunit.xml
├── src
├── Fitztrev
│ └── LaravelHtmlMinify
│ │ ├── LaravelHtmlMinifyCompiler.php
│ │ └── LaravelHtmlMinifyServiceProvider.php
└── config
│ └── config.php
└── tests
└── BaseMinifyTest.php
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor
2 | composer.phar
3 | composer.lock
4 | .DS_Store
5 |
6 | report
7 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | php:
4 | - 5.3
5 | - 5.4
6 | - 5.5
7 |
8 | before_install:
9 | - wget http://cs.sensiolabs.org/get/php-cs-fixer.phar
10 |
11 | before_script:
12 | - composer self-update
13 | - composer install --dev
14 |
15 | script:
16 | - phpunit
17 | - output=$(php php-cs-fixer.phar fix -v --dry-run --level=psr2 .); if [[ $output ]]; then while read -r line; do echo -e "\e[00;31m$line\e[00m"; done <<< "$output"; false; fi;
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013 Trevor Fitzgerald
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## UPDATE for Laravel 5/5.1+
2 |
3 | Read my preferred way of minifying HTML in Laravel 5/5.1+ apps here: [Using Gulp to Minify Laravel Blade Templates](https://github.com/fitztrev/laravel-html-minify/wiki/Laravel-5---5.1-HTML-Minifying)
4 |
5 | ---
6 |
7 | # Laravel HTML Minify
8 |
9 | ### For Laravel 4 - See [here](https://github.com/fitztrev/laravel-html-minify/wiki/Laravel-5---5.1-HTML-Minifying) for L5+
10 |
11 | [](https://travis-ci.org/fitztrev/laravel-html-minify)
12 | [](https://packagist.org/packages/fitztrev/laravel-html-minify)
13 |
14 | ## About
15 |
16 | This package compresses the HTML output from your Laravel 4 application, seamlessly reducing the overall response size of your pages.
17 |
18 | 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.
19 |
20 | ## Why?
21 |
22 | Even with gzip enabled, there is still an improvement in the response size for HTML content-type documents.
23 |
24 | Test Page | w/o Gzip | w/ Gzip | w/ Gzip + Laravel HTML Minify
25 | --- | ---: | ---: | :---:
26 | **#1** | 8,039 bytes | 1,944 bytes | **1,836 bytes** (5.6% improvement)
27 | **#2** | 377,867 bytes | 5,247 bytes | **4,314 bytes** (17.8% improvement)
28 |
29 | ## Installation
30 |
31 | 1. Add `"fitztrev/laravel-html-minify": "1.*"` to **composer.json**.
32 | 2. Run `composer update`
33 | 3. Add `Fitztrev\LaravelHtmlMinify\LaravelHtmlMinifyServiceProvider` to the list of providers in **app/config/app.php**.
34 | 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 {} \;`
35 |
36 | ## Config
37 |
38 | Optionally, you can choose to customize how the minifier functions for different environments. Publish the configuration file and edit accordingly.
39 |
40 | $ php artisan config:publish fitztrev/laravel-html-minify
41 |
42 | ### Options
43 |
44 | - **`enabled`** - *boolean*, default **true**
45 |
46 | If you are using a javascript framework that conflicts with Blade's tags, you can change them.
47 |
48 | - **`blade.contentTags`** - *array*, default `{{` and `}}`
49 | - **`blade.escapedContentTags`** - *array*, default `{{{` and `}}}`
50 |
51 | #### Skipping minification
52 |
53 | To prevent the minification of a view file, add `skipmin` somewhere in the view.
54 |
55 | ```
56 | {{-- skipmin --}}
57 |
58 | ```
59 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fitztrev/laravel-html-minify",
3 | "description": "Minifies the HTML output of Laravel 4 applications",
4 | "keywords": ["laravel", "l4", "html", "optimization", "performance", "compress", "minify", "minifier", "blade"],
5 | "homepage": "https://github.com/fitztrev/laravel-html-minify",
6 | "license": "MIT",
7 | "authors": [
8 | {
9 | "name": "Trevor Fitzgerald",
10 | "email": "fitztrev@gmail.com"
11 | }
12 | ],
13 | "require": {
14 | "illuminate/view": "4.x"
15 | },
16 | "require-dev": {
17 | "mockery/mockery": "dev-master",
18 | "phpunit/phpunit": "3.7.*",
19 | "phpunit/php-code-coverage": ">=1.2.10,<1.3.0"
20 | },
21 | "autoload": {
22 | "psr-0": {
23 | "Fitztrev\\LaravelHtmlMinify": "src/"
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
or