OddOneOut / bwp-minify

A WordPress Minification plugin that relies on Minify PHP library and WordPress's enqueueing system to serve minified CSS and JS to your audience
http://betterwp.net/wordpress-plugins/bwp-minify/
49 stars 23 forks source link

Deactivate plugin on ie9 #42

Open sachacohenfr opened 9 years ago

sachacohenfr commented 9 years ago

Good plugin but IE9 does not support big css files (4095 css selector), so it's could better with a way to deactivate it on IE9 ;-)

kminh commented 9 years ago

Can you provide more info on this matter? Some links would be good. Thanks.

A workaround is to use fewer files per minify string, have you tried that?

dave-newson commented 8 years ago

It's a classic IE <=9 bug that really screws with minifiers. This should refer to more than just IE9. https://blogs.msdn.microsoft.com/ieinternals/2011/05/14/stylesheet-limits-in-internet-explorer/

A sheet may contain up to 4095 rules A sheet may @import up to 31 sheets @import nesting supports up to 4 levels deep

mrclay/minify doesn't have any concessions for IE, and has a warning in its readme:

If you combine a lot of CSS, watch out for IE's 4096 selectors-per-file limit, affects IE 6 through 9.

As a side note, if you don't split the grouping of files by a reasonable number, you might also run into the long URL issue (minify URL is too long for the server), so you're kind-of stuck limiting the number of files you include anyway.

A safer solution would be to add any file with a large number of selectors to the "do not minify" group. This is a bit crappy though because it requires an awareness of the IE 4095 rule by the developer on a case-by-case basis. It makes BWP Minify a less drop-in one-size-fits-all solution.

On a personal note, I hate the "solution" used by BWP Minify and mrclay/minify of requiring the developer to batch fewer files for minify. That sacrifices some optimisation for the sake of "its really haaaard".

BWP would instead need to inspect the CSS files and detect the number of rules, then split the files at intervals where the number of rules exceeds this limitation. That can't happen on every page load as BWP would have to load the files, which would incur request penalties. There are some possible solutions to that, like caching more metadata about CSS files and generating hashed cache files to group the requested items, allowing minify to grab the files by a short URL rather than by the actual file paths.

That would be a heavy departure from BWPs current grab/group/minify approach, though.