- if (cond) foo(); else bar(); ==> cond?foo():bar(); - if (cond) foo(); ==> cond&&foo();
…- it's possibly a global defined elsewhere
- name mangling is now smarter -- don't shadow previously mangled names when they're referenced from sub-scopes - use a simpler algorithm to 'compute' mangled names (base54) - add parens around sequences when they are operands in a binary operator - add parens around expression in "sub" when it's not a simple one - disabled removal of brackets in a "then" clause (needs more thinking) On minifying jQuery we're better than YUI by 5.8K: -rw-r--r-- 1 mishoo mishoo 79337 2010-08-14 13:39 /tmp/jq-yui -rw-r--r-- 1 mishoo mishoo 73444 2010-08-14 13:38 /tmp/jq-mine
…en in KEYWORDS" construct everywhere, and it doesn't work well because jQuery defines a lot of variables using names that have some standard meaning in JS, such as "toString". "toString" in OBJECT will always evaluate to true, since all objects have a "toString" method, but it's not what we expect. Take two was to replace all these constructs with foo.hasOwnProperty(bar), which didn't work either for jQuery because it defines a variable called "hasOwnProperty". When parsing the scope, I put all the variable names in a hash and later I'm calling that hash.hasOwnProperty(varname) to determine wether the variable is in scope or not. But "hasOwnProperty" was already something else in that hash. :-) Cool, isn't it. So I added the HOP function which does: return Object.prototype.hasOwnProperty.call(hash, key); and now we're flawless.
consecutive var decls in switch blocks)
…ator. It's now beating YUI compressor by 2.4KB (and by many long seconds :-p) on the DynarchLIB code.
…ver all cases)
… the first character)