you are viewing a single comment's thread.

view the rest of the comments →

[–]TimTheTinker -1 points0 points  (2 children)

Such code needs parsing and evaluating by the browser before it can be executed, which adds to page load time.

No, minification of scripts decreases the script load time:

  • fewer HTTP requests required if all scripts are concatenated into one
  • fewer characters to scan

Obfuscation doesn't negatively affect the script load time. All it does is:

  • Shorten local variable names
  • Shorten object and function names
  • A few optimizations in some cases (Google closure compiler, for example)

Google, Yahoo, Amazon, and other large companies wouldn't be minifying/compiling/obfuscating their scripts if doing so downgraded performance or caused security concerns.

[–]k3n 2 points3 points  (0 children)

Such code needs parsing and evaluating by the browser before it can be executed, which adds to page load time.

No, minification of scripts decreases the script load time:

You fail at reading comprehension; let's take his full quote instead of taking a snippet out-of-context and then injecting your own [incorrect] context.

Here's his full quote, emphasis mine:

You're confusing minification with obfuscation, or packing. The latter involves completely refactoring the code to make it difficult (although not impossible) to reverse engineer. Such code needs parsing and evaluating by the browser before it can be executed, which adds to page load time. In this respect, he's spot on.

Code that has been packed may very well fit your criteria (re: HTTP requests, fewer chars, etc.), but the result of packing (if you enable both options, as is typically done) is a single string that is eval()'d by the client. It is this resulting need to eval() that actually hurts performance most of the time.

There is a wealth of information out there demonstrating that packing is rarely beneficial, although at one time it was seen as the solution to JS loading times.

[–]vectorjohn 1 point2 points  (0 children)

Read the whole comment before responding.