On Sun, Dec 14, 2008 at 1:58 AM, Daniel Friesen <dan_the_man(a)telus.net> wrote:
Erm... so you're saying we should go and turn
this:
...
Into this:
if(fooBar){
var baz=false;
var x=0;
while(!baz){
if(x==260){
baz=true;
}
if(x==25){
runThis({
a:'b',
c:'d'
});
}
x++;
}
if(x>55)
andRunThis(fooBar);
}
Readable enough if you just need to figure out what the relevant line
is doing, sure. You can then go to the actual wikibits.js or
whatever, using the extra ?jsdebug=1 or whatever, and make sure it
matches up if there's a problem.
Minification killing debugging isn't just because
of it destroying
newlines. I honestly don't want to pop between places to debug things.
Do remember that some of us like to debug within the browser. FireFox
with FireBug for one very nicely lets me jump to where an error happened
in the code and breakpoint it as well.
Remember that this would only be necessary if the problem didn't also
occur for the unminified version. If it did (which should be almost
always), you can just use that.
But not only that, plenty of the optimization that
comes from
minification is because it completely removes comments. There's little
point to minifying if you're only going to minify half way.
You get the worst of both worlds. Hard to read code, and your filesize
still hasn't changed much.
Sure it has. This comment:
/**
* Add a link to one of the portlet menus on the page, including:
*
* p-cactions: Content actions (shown as tabs above the main content
in Monobook)
* p-personal: Personal tools (shown at the top right of the page in Monobook)
* p-navigation: Navigation
* p-tb: Toolbox
*
* This function exists for the convenience of custom JS authors. All
* but the first three parameters are optional, though providing at
* least an id and a tooltip is recommended.
*
* By default the new link will be added to the end of the list. To
* add the link before a given existing item, pass the DOM node of
* that item (easily obtained with document.getElementById()) as the
* nextnode parameter; to add the link _after_ an existing item, pass
* the node's nextSibling instead.
*
* @param String portlet -- id of the target portlet ("p-cactions",
"p-personal", "p-navigation" or "p-tb")
* @param String href -- link URL
* @param String text -- link text (will be automatically lowercased
by CSS for p-cactions in Monobook)
* @param String id -- id of the new item, should be unique and
preferably have the appropriate prefix ("ca-", "pt-", "n-"
or "t-")
* @param String tooltip -- text to show when hovering over the link,
without accesskey suffix
* @param String accesskey -- accesskey to activate this link (one
character, try to avoid conflicts)
* @param Node nextnode -- the DOM node before which the new item
should be added, should be another item in the same list
*
* @return Node -- the DOM node of the new item (an LI element) or null
*/
gets turned into 28 bytes or so. And the large runs of newlines will
undoubtedly compress very well, too. I doubt there's a substantial
difference in the size depending on whether you include newlines or
not. But benchmarking's the only way to test, right? The evidence
that minification helps for large amounts of JS are fairly unequivocal
(see, e.g., Steve Souders' "High Performance Websites").