renatomarinho / laravel-page-speed

Package to optimize your site automatically which results in a 35%+ optimization
MIT License
2.42k stars 279 forks source link

CollapseWhitespace to ignore certain HTML elements #96

Closed TivoSoho closed 5 years ago

TivoSoho commented 5 years ago

Description

Middleware CollapseWhitespaces trim whitespaces and new lines inside HTML elements it should not touch and thus it is breaking functionality, even perhaps entire sites.

Motivation and context

We have inline JS, CSS and use pre and textarea. Inline JS for example is in our page layout so there is no option to skip a route - it would mean skipping everything. As such there needs to be a way to skip HTML elements whose content you shouldn't be modifying. This is only a continuation of the fork by SergeyPodgornyy (https://github.com/renatomarinho/laravel-page-speed/pull/81) which does not address all the HTML elements that need skipping. This adds some missing ones and modifies the code so that other HTML elements can be added as well if you need more skipped.

How has this been tested?

So far testing in our own production site. I know my PR won't be accepted without tests, which I am unsure how to do.

Screenshots

image

Types of changes

Checklist:

joaorobertopb commented 5 years ago

Thanks for this PR.

Not sure of making that kind of change for now. To merge this PR, we would have to do tests covering these changes...

I will focus on fixing bugs for now, thanks.