4 ms·
I get concerned that these minimisers and js to js compilers will introduce subtle bugs and changes into the behaviour of my code. Is that concern warranted?
by lupin_sansei 17y ago
I get concerned that these minimisers and js to js compilers will introduce subtle bugs and changes into the behaviour of my code. Is that concern warranted?
- seiji 17y agoClosure advanced mode will absolutely screw with your code. Closure simple mode and YUI Compressor won't change the behavior of your code. They just rename completely encapsulated objects with shorter names and remove unnecessary semicolons.
- sh1mmer 17y agoThis is one of the things I've been wondering about. I'd like to look at ways to get Closure to be more holistic in it's approach. YUI Compressor has always been safe. I think the concern I have is that the new, exciting features here are the unsafe ones and, obviously, those are the ones that are dangerous. I'd be really interested in seeing how we can make features like this safe again. For example, by scraping a page, rather than just a JavaScript file to see which methods are genuinely unused instead of those unused in an undefined context of an unlinked JS file.
- gruseom 17y agoIf the Closure "compiler" changes the behavior of a program, that means it's generating incorrect code. Can you give an example?
- seiji 17y agoCheck out http://code.google.com/closure/compiler/docs/api-tutorial3.html#propnames http://code.google.com/closure/compiler/docs/api-tutorial3.h... (short version: inconsistencies between Closure renaming my_object.attribute to a minified a.a while in other places you use my_object['attribute'] which it can't minify to be a.a. You end up with a.a = 3 and a['attribute'] = {something else}).
- gruseom 17y agoAh. This is a classic problem with transforming JS. We've run into something similar with Parenscript (but were able to correct it, rather than say "just don't write code that does X").