[close #233] Allow to register new archivers to make some compressions to asset file - #241
[close #233] Allow to register new archivers to make some compressions to asset file#241iggant wants to merge 3 commits into
Conversation
|
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
|
Thank you for the pull request. I prefer to reintroduce the encoding negotiation API for this sstephenson#589. |
|
But this is completelly different usecases. when you make you don't have encoding string. Therefor in production mode I have I precompile assets and make some addition formats (like webp, jpeg-xr, etc) (it will take some additional space, but space is extremly cheap now), So users will get the best performance I can provide for their browser. Why I don't want to compile assets on the fly: first of all performance reason (even if I use cloudfrond or similar), first user won't get asset immediatly. |
|
That API is not only to compile assets on the fly, we can use the same API to precompile assets. It is the same we have with transformations (coffee -> js, sass -> css, etc.). |
| end | ||
|
|
||
| # Public: Checks if Gzip is enabled. | ||
| def gzip? |
There was a problem hiding this comment.
Since this is not coupled to gzip anymore we may need to change these methods. Like archiver_enabled? skip_archiver? and archiver=.
|
@rafaelfranca add new method, but for compability left gzip? method but add deprecation warning note |
| # will register Zlib compression for text file, | ||
| # we dont use myme_types here, because different mime_type | ||
| # can be compressed by one archiver (text/stylesheets, text/javascript, etc) | ||
| def register_archiver type, archiver |
There was a problem hiding this comment.
Put parentheses in the method definitions.
|
sorry for delay, I've rewrite slightly, and simplify a lit bit. If archiver is registered it counts as active otherwise we dont know about |
|
I gave this my own spin at #372. |
If archiver've registered it counts as active
|
Zopfli and an archiver interface (called exporters) are merged into master. Check out the docs and source if you need to write one. Or ping me with questions on this thread. Thanks for your input. The final solution was a result of everyone's inputs and help. |
|
can you create beta4 version with this changes |
|
Done. |
This commit allow to register new archiver.
Can easily replace existing gzip implementation to zopfli (as it show in the #233 it can give about 3% space compressing)
Allow to add new archivers such as generate .webp image format for chrome or JPEG-XR for IE, that will help to reduce image size for that browsers)
We can't use it as preprocessor/postprocessor because not all browsers support this format, but will help for precompiled assets, it will compile longer but will reduce overall site size.