-
-
Save michaellouieloria/10270934 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* An improvised Gist from | |
* https://gist.github.com/zmsaunders/5619519 | |
* https://gist.github.com/garagesocial/6059962 | |
*/ | |
App::after(function($request, $response) | |
{ | |
if(App::Environment() != 'local') | |
{ | |
if($response instanceof Illuminate\Http\Response) | |
{ | |
$output = $response->getOriginalContent(); | |
$filters = array( | |
//Remove HTML comments except IE conditions | |
'/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->).)*-->/s' => '', | |
// Remove comments in the form /* */ | |
'/(?<!\S)\/\/\s*[^\r\n]*/' => '', | |
// Shorten multiple white spaces | |
'/\s{2,}/' => '', | |
// Collapse new lines | |
'/(\r?\n)/' => '', | |
); | |
$output = preg_replace(array_keys($filters), array_values($filters), $output); | |
$response->setContent($output); | |
} | |
} | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment