Hacker News new | past | comments | ask | show | jobs | submit | zertosh's comments login

Articles like this miss the _true_ genius of jQuery – that it basically wraps all DOM operations in a maybe monad. You get null safety for free.


One could ask if that's actually a good thing.

You also get the same thing from the existential operator in coffeescript, if you're in to that.


You read my mind. That was one of the sources I was going through that motived me to make this.


I'm the author. I've made extensions for Chrome before (https://github.com/zertosh/jquery-audit) and I don't think I can incorporate this in a nice way. I'll look into FF. As for a standalone site, I really dig that idea - stay tuned. I'm also learning more about the Uglify internals to submit this as a patch.


I'm the author. Since "a", "b", "c" get recycled by different scopes, it makes it really hard to figure out which "a" you're looking that. By having unique names, you can easily spot where one variable is used exclusively. I was going to use a dictionary but I didn't want the tool to be language specific or run into unsavory words.


>> I didn't want the tool to be language specific or run into unsavory words

Good thoughts. However, "beedip" is foreign to everyone, whereas if you pick a language, it's at least native to some people.

Also, you could have maybe 50 known inoffensive words; there probably aren't more than that many unique variables in a scope. Things like "hat" and "bread".


Why don't you prefix variables based on their usage in the code?

function(a,b,c) -> function(arg1_cat, arg2_tree, arg3_carrot)

for(i=0; i< 10; i++) -> for(counter1=0; counter1 < 10; counter1++)

var a -> var global_pants;

You could do this reasonably well with regular expressions/find+replace.

To be more sophisticated you would use a a tokenizer/parser and rename based on the identifiers location in the AST nodes. I did something similar a few years ago for a commercial product that included a JavaScript beautifier and our customers loved it.


Or perhaps a consistent "namespace", e.g. with a standard prefix prepended to a simple noun.


You could use first names as your dictionary. The US Census Bureau has lists† (in the form of frequency tables) of male and female given names.

http://www.census.gov/genealogy/www/data/1990surnames/names_...


I'm the author. Search-and-replace is the main problem this solves. Another neat effect is that if you use something like Sublime Text, you can highlight a word (variable), and see all the occurrences. Makes it much easier to figure out what unminifed code is doing without all the collisions from "h" for example.


Makes sense. I would add that tip to the readme. I don't think it will be immediately obvious to people, so bringing attention to the ability to find and replace will make the renaming a more attractive feature.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: