Prototype compressed
Category javascript
For those looking for a compression-safe version of the recently released Prototype 1.5.0, look no further. The ZIP contains a syntactically corrected version, both in compressed (29 KB) and uncompressed (74 KB) form. While I haven't addressed absolutely every issue reported by JSLint, all semicolons and curly braces have been inserted where necessary.
For the curious, something perhaps worthy of note: although some balk at the stringency of JSLint, one seemingly nitpicky issue it scans for that I definitely agree with (and applied to the above files) is appropriate use of equality operators. For example:
if (someVariable == null) {
should instead be:
if (someVariable === null) {
Why? Because JavaScript is loosely typed. Two equals signs asks whether the operands have an equivalent value; three equals signs asks if the operands are references to the same object. A variable with a value of null or undefined is actually treated as a reference to, respectively, the null or undefined object. In other words, the former actually forces a temporary type coercion. As a result, the latter is more efficient. Same goes for the opposite evaluation (!= vs. !==). So it may seem "anal" to be checking for this, but code that contains enough of these evaluations will run noticeably faster if the correct operator is used. I highly recommend Douglas Crockford's tutorial videos (currently available in the YUI Theater) to anyone interested in these and other useful observations into the nature of JavaScript.
For those looking for a compression-safe version of the recently released Prototype 1.5.0, look no further. The ZIP contains a syntactically corrected version, both in compressed (29 KB) and uncompressed (74 KB) form. While I haven't addressed absolutely every issue reported by JSLint, all semicolons and curly braces have been inserted where necessary.
For the curious, something perhaps worthy of note: although some balk at the stringency of JSLint, one seemingly nitpicky issue it scans for that I definitely agree with (and applied to the above files) is appropriate use of equality operators. For example:
if (someVariable == null) {
should instead be:
if (someVariable === null) {
Why? Because JavaScript is loosely typed. Two equals signs asks whether the operands have an equivalent value; three equals signs asks if the operands are references to the same object. A variable with a value of null or undefined is actually treated as a reference to, respectively, the null or undefined object. In other words, the former actually forces a temporary type coercion. As a result, the latter is more efficient. Same goes for the opposite evaluation (!= vs. !==). So it may seem "anal" to be checking for this, but code that contains enough of these evaluations will run noticeably faster if the correct operator is used. I highly recommend Douglas Crockford's tutorial videos (currently available in the YUI Theater) to anyone interested in these and other useful observations into the nature of JavaScript.







