-
Notifications
You must be signed in to change notification settings - Fork 799
Zopfli gzip #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zopfli gzip #233
Conversation
|
Since zopfli still generates gzip output I don't think we need to have another class i.e. i think the "gzip" name class name is fine. What if we abstract out the actual archiver parts into their own class and give them a # utils/compression/zlib_archiver.rb
#...
class ZlibArchiver
def call
# ...
end
endThen we could have a module Sprockets
module Utils
class Gzip
# Private: Generates a gzipped file based off of reference file.
def initialize(asset, archiver = ZlibArchiver)
@archiver = archiver
# ...
def compress(target)
mtime = PathUtils.stat(target).mtime
PathUtils.atomic_write("#{target}.gz") do |f|
@archiver.call(target: target, source: @source, mtime: mtime)
File.utime(mtime, mtime, f.path)
end
nil
endThat way the logic of if an object can be compressed and the atomic writing will stay in this gzip object, but the logic of the actual compression can live in a purpose built module/class/proc. We could then use this inside of the manifest like this |
|
@schneems yes, now this is much better, |
|
I like it. For applications that don't compile assets in production (which they shouldn't do anyway!), we should be willing to trade compilation time for reduced asset size. Needs a rebase. |
|
@nateberkopec |
|
I think this would be a big, easy win for all Sprockets users. Has there been any progress on merging this? |
|
I made a gem that is based on #372: https://github.com/hansottowirtz/sprockets-exporters. It lets you add a |
Looks like it needs a rebase. There's also a few issues we mentioned above. |
|
Zopfli is now in master |
Can you please have a look at this propose:
After reading http://blog.codinghorror.com/zopfli-optimization-literally-free-bandwidth/ this article, I've started experimenting with zopfli gzip optimization.
and I have this parameters:
Zopfli gzip:
Normal gzip
So we have 3,31% size improvment, but this takes about 14% longer to compile
I don't add zopfli as default archiver but if you want, you'll be able to process gz, using zopfli archiver.