Posts

Showing posts with the label packed

Last Version Of JSON Hpack

Update created github repository with (currently) JavaScript, PHP5 and Python versions. Update after quick chat on twitter with @devongovett who pointed out there is a similar standard called JSONDB I have created a JSONH(Flat) version . It looks slightly faster on mobile so I may opt for this one rather than Array of keys at index 0. The whole array is flat and it changes from [{a:"A"},{a:"B"}] to [1,"a","A","B"] where the empty collection would be [0] rather than [[]] . Also more details here on how to JSONH Hybrid JS Objects . A while ago I proposed a homogeneous collections optimizer nick named JSON.hpack . What I wasn't expecting is that actually different projects and developers adopted this technique to shrink down JSON size. Basic Advantage Of JSON.hpack Gzip and deflate work really good with repeated chunks of strings and this is why homogeneous collections have really good compression ratio there. However, gzip...

On My Vicious JavaScript Code

Disclaimer This post is a reply to kangax question : I’m sorry but why such vicious coding style? I'd like to explain my point of view about JavaScript code style so, if interested, please read until the end, thank you :) Some Background I study and use JavaScript since year 2000 and one of the most interesting thing about this language is that even if it is "that old" you never stop to learn something new (techniques, strategies, adapted patterns, etc). At the same time, the " biggest trouble " of this language is its weight in a page, which is the reason we all use minified and gzipped or packed versions of our application. Coming from a " 33Kb modem internet era " I always tried to pay attention about the size and I studied and created both a JavaScript minifier and a compressor . Compressors Rules Unless we are not using an " incremental " compressor, as GIF is, we should consider that packer algorithm, as gzip and deflate , are dicti...

Bases, merits, and defects of packed code

How many times we have seen an included JavaScript apparently incomprehensible? These examples could explain better what I mean: packed.it via MyMin eval((function(M,i,n){return '0("1");'.replace(/\w+/g,function(m){return (n[m]!=i[m]&&i[m])||(i[m]=M[parseInt(m,36)])})})('alert.test'.split('.'),{},Object.prototype)) Dean Edwards packer eval(function(p,a,c,k,e,d){e=function(c){return c};if(!''.replace(/^/,String)){while(c--)d[c]=k[c]||c;k=[(function(e){return d[e]})];e=(function(){return'\w+'});c=1};while(c--)if(k[c])p=p.replace(new RegExp('\b'+e(c)+'\b','g'),k[c]);return p}('1('0');',2,2,'test|alert'.split('|'),0,{})) These are only two parsers which aim is to reduce code size using an inline decompression technique that is able to evaluate source code after common keywords replacement. Basis of portable and packed code The main goal of these services is to compress a source...