Open ggrossetie opened 5 years ago
gzip
version 1.6+ installed$ ls -s build/asciidoctor-browser.js
1808 build/asciidoctor-browser.js
java -jar closure-compiler-v20190121.jar --jscomp_off=undefinedVars --js_output_file=build/asciidoctor-browser.min.js --compilation_level=ADVANCED build/asciidoctor-browser.js
$ ls -s build/asciidoctor-browser.min.js
636 build/asciidoctor-browser.min.js
gzip -9 < build/asciidoctor-browser.min.js > build/asciidoctor-browser.min.js.gz
$ ls -s build/asciidoctor-browser.min.js.gz
180 build/asciidoctor-browser.min.js.gz
The file size decreased by a factor of 10, from 1808 Kbytes to 180 Kbytes.
//cc @rmannibucau @mojavelinux
That reduction in size is stunning! Fantastic work!
Sounds awesome, thanks a lot!
I'm now down to 168 Kbytes with https://github.com/asciidoctor/asciidoctor.js/pull/669
1704 build/asciidoctor-browser.js
596 build/asciidoctor-browser.min.js
168 build/asciidoctor-browser.min.js.gz
:open_mouth: Aaaaamazing.
@Mogztter are these numbers still accurate on master (using Asciidoctor 2)? I'm getting 633K after running the closure compiler and 180K after running gzip on that result.
I see in the 2.0.0 RC2 release, the size of the minified file is 627K.
Yes the minified+gzip should be around 180K.
Gotcha. So we crept up a little bit from your last report, but not by too much.
I just realized we could probably get rid of the Float#truncate patch. Opal implements precision on truncate, so there's no reason to have that require pulled in. It won't save much, but it's something.
@Mogztter I was thinking you might be able to find unless RUBY_ENGINE blocks and strip the empty block (though perhaps the optimizer already does that). (Though, perhaps Opal should leave these blocks behind in the first place).
For example:
unless RUBY_ENGINE == 'opal'
puts 'not opal'
end
produces
(function(Opal) {
var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice;
Opal.add_stubs(['$==']);
if ($$($nesting, 'RUBY_ENGINE')['$==']("opal")) {
return nil
} else {
return nil
}
})(Opal);
https://github.com/asciidoctor/asciidoctor.js/issues/647#issuecomment-452270256