Results 1 to 2 of 2

Thread: DEFLATE-ing popular Javascript libraries

  1. #1
    Member
    Join Date
    Mar 2013
    Location
    Berlin
    Posts
    45
    Thanks
    14
    Thanked 71 Times in 30 Posts

    DEFLATE-ing popular Javascript libraries

    About two out of three major websites are based on the jQuery Javascript library. jQuery 2.1.4 weights about 250kb and code minification brings it down to 82kb. GZIP compression reduces the number of bytes to be transferred to 34418 bytes (official download at http://code.jquery.com).

    I was surprised to find that a simple gzip -9 produced a significantly smaller file (29539 bytes). Since jQuery is pretty much a textbook example of "compress once, decompress a gazillion times", I started to play around with various DEFLATE encoders. My intention was to spend tons of CPU cycles while compressing in order to save every byte possible.

    Google's Zopfli, especially Krzymod's fork, produces the best results, which can be found here:
    http://minime.stephan-brumme.com/jquery/2.1.4/. kzip and 7zip are included in my tests as well.

    These promising numbers gave me a push to include older jQuery versions as well as other popular Javascript libraries, such as AngularJS, BackboneJS, Bootstrap, D3, Dojo, Ember, Knockout, React and UnderscoreJS. Go to http://minime.stephan-brumme.com to get more details.

    Moreover, I downloaded these libraries from their original websites and from major public content delivery networks like Google, Microsoft, cdnJS, jsdelivr, Yandex and Boot. With a few exceptions they all fail to be even comparable to gzip -9. I have no idea why because smaller files would directly lead to reduced network costs.

    For those who feel the urgent need to take a peek inside these compressed files, I wrote a simple DEFLATE decompressor in Javascript which visualized the Huffman tables and LZ77 matches of the smallest GZIPped files (scroll down to the bottom of the page to the "Detailled Analysis" and press the button "Load and Parse Data").

  2. The Following 3 Users Say Thank You to stbrumme For This Useful Post:

    Cyan (31st January 2016),Jyrki Alakuijala (31st January 2016),Mr_KrzYch00 (30th January 2016)

  3. #2
    Member Mr_KrzYch00's Avatar
    Join Date
    Apr 2015
    Location
    Poland
    Posts
    65
    Thanks
    10
    Thanked 40 Times in 24 Posts
    I'm amazed with Your work. :)

    I noticed that Zopfli resumed developing process, however, those changes are not yet up in KrzYmod fork as I have no time to manually merge so many changes at the moment, neither to even compile original project.

    I wonder if those latest changes improve compression with original zopfli. hmm.

    * KrzYmod is the name for the fork I have chosen to use, so for the sake of correctness, it should be called Mr_KrzYch00's Zopfli fork, aka. Zopfli "KrzYmod" :)

    EDIT: Ah yes, I forgot to mention. You could still get better results with Zopfli "KrzYmod" fork when using --cbs command to finetune block splitting point(s). That would certainly give different results. Back when I was doing my tests, sometimes using kzip split points with zopfli compression algorithm provided better results than using other various Zopfli settings alone.
    Last edited by Mr_KrzYch00; 30th January 2016 at 22:24.

Similar Threads

  1. Intel brings SIMD to JavaScript
    By nburns in forum The Off-Topic Lounge
    Replies: 60
    Last Post: 22nd July 2014, 00:26
  2. Replies: 2
    Last Post: 18th April 2011, 04:13
  3. javascript file uploader
    By Shelwien in forum Download Area
    Replies: 7
    Last Post: 18th August 2010, 17:03
  4. Standard for compression libraries API
    By Bulat Ziganshin in forum Data Compression
    Replies: 47
    Last Post: 30th March 2009, 06:10
  5. QuickLZ ZIP - new zip/deflate library
    By Lasse Reinhold in forum Forum Archive
    Replies: 23
    Last Post: 1st October 2007, 22:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •