fitztrev / laravel-html-minify

Minifies the HTML output of Laravel 4 applications
https://github.com/fitztrev/laravel-html-minify/wiki/Laravel-5---5.1-HTML-Minifying
MIT License
414 stars 76 forks source link

Doesn't minify views with <script> tags within it #40

Closed modenaa closed 10 years ago

modenaa commented 10 years ago

Hi

I am facing an issue, where none of the segements or whole pages where the script tag is present is being minifed. As soon as I remove it, works fine, these include script tags covering google analytics, all the way to other third party add ons.

Thanks

GrahamCampbell commented 10 years ago

That is the expected behavior. https://github.com/fitztrev/laravel-html-minify/blob/master/src/Fitztrev/LaravelHtmlMinify/LaravelHtmlMinifyCompiler.php#L48

fitztrev commented 10 years ago

@GrahamCampbell is correct. At this time, the script takes a conservative approach and does not minify inline javascript. Reason being that whitespace in javascript does matter and your site could break if it's removed.

As an alternative, and what I do, is just create a view partial that has just the Google Analytics snippet in it. Then include that from your other view.