skeeks-semenov / yii2-assets-auto-compress

Automatic compilation of js + css + html
https://skeeks.com/
BSD 3-Clause "New" or "Revised" License
157 stars 43 forks source link

Skip (re-)minification of already minified files, e.g. *.min.js and *.min.css #19

Open adoerler opened 7 years ago

adoerler commented 7 years ago

Hi,

this extension is awesome.

To speed things up, it would be great to skip files ending with .min.css or .min.js from running again through e.g. CssMin::minify.

Best thing would be to have this configurable per AssetBundle, but I'm not sure if this will be possible. On the other hand a regex (configurable in the assetsAutoCompress configuration array) could do the job.

What do you think?

Kind regards from Austria Andreas

skeeks-semenov commented 7 years ago

@adoerler You propose to add settings. Regular file name expression to pass, and do not handle. And just intact, adding to compress file?

adoerler commented 7 years ago

Hi,

thank's for your fast response!

WP-Plugin Autoptimize has added such a feature in release 2.0 (https://tah.wordpress.org/plugins/autoptimize/faq/).

They state:

One of the bigger changes in Autoptimize 2.0 is that files that have "min.js" or "min.css" in their name are considered already minified and are only injected into the aggregated code after the actual minification, because this has an important performance-benefit. Although this has been tested rather thoroughly, it is possible that this approach does not always work. You can turn this behavior off by hooking into Autoptimize's API

I think one could profit from faster performance if source is already minified. Additionally one could add exceptions for certain files if minification fails for unkown reasons.

Configuration could be an array of regular expressions, like:

cssFileCompressExceptions = [
'.min.css$',
'otherfile.css'
]

Andreas

skeeks-semenov commented 7 years ago

Additionally one could add exceptions for certain files if minification fails for unkown reasons.

I think this is the main reason why the need to make such a revision.

As is, in principle, once processing. And then all cached, and not very resource-intensive. I'll try to do it later.

adoerler commented 7 years ago

I think this is the main reason why the need to make such a revision.

you are right, this is also a very good reason having this configurable. After adding Swiper (http://idangero.us/swiper/#.WACVrOiLSUk) as Asset the CSSMin component your are using failed due to parantheses in url data. This was a point where the stated functionality helped out. (On the other hand, the guys at Natxet have been very fast with fixing - https://github.com/natxet/CssMin/pull/22 :-)

Andreas