asset_compress
asset_compress copied to clipboard
Should auto included javascript controller/view files be minifed?
I expected auto included js files to be minified according to the filters set up in asset_compress.ini. But the files that are included are not processed in any way. After looking at the code in AssetCompressHelper.php this is the intended behavior, but stands in contrast with the v0.5 changelog "Controller/view javascript files are now combined into minified asset automatically now.".
Am I missing something? Is there any way to automatically minify these files?
They aren't automatically minified as that would require generating build file definitions for them or using the dynamic build files, which are not supported in the standard non debug deployment case.
What I'm looking for is simply minifying those files. I was thinking about adding a setting in asset_compress.ini 'filter_autoincluded'. If this would be set to true, running a shell build command would search for .js files in /js/views/*, run them through the filters, and finally save the filtered version to the cache path(preserving the directory structure).
So for example for an unfiltered file /js/views/posts/index.js we would end up with a filtered version of that file in /cache_js/views/posts/index.js. The helper would check the setting, check if the minified version exists, if not fall back to original. Simple and it works. Would you be willing to pull in such a feature? Maybe you have a better idea?
That seems like a reasonable way to do things. Having the build shell walk those directories and minify each file into a mirrored directory structure in the cachePath will be simple and makes sense to me.
Hi. Was wondering if there was any news on this one, that's a feature I would be very interested in (especially if it could also support the $timestamp options). Thanks
There hasn't been any change here. I don't personally use this feature. Getting the autoincluded scripts working with the filter system might be a bit awkward. If you would like to take a stab at it, please do.
OK, thanks. I'll revisit this issue later, already took me a while to backport some of the recent changes on top of v0.5, we are still using CakePHP 1.3 here :) Thanks for this plugin, really helps.
Welcome :) I think the dynamic build files needs to be rethought in general. I find having two ways to create builds is awkward but I've not yet come up with a good way to unify them. If you have any thoughts on how the dynamic build files could be improved let me know.
@sebastienbarre Are you still interested in that feature? Maybe a PR with your proposed changes would speed things up and gets it merged in quicker.
@dereuromark I still am, though the changes were proposed by @tmazur
Ops ;) Well then the PR advice goes to him then.
After looking into how this feature might be implemented, the required time overwhelmed me, and I put this on my 'todo some day far away' list. Anyway, if I find some spare time I will implement this feature and create a PR.