Live data from Hacker News

Show HN: Beautify-with-words unminifies JS with unique words for variable names

github.com

21–30 of 35 posts

Re: Show HN: Beautify-with-words unminifies JS with unique words for variable names

#21
post #20

Neat. More useful for projects without unminified sources, like Google Analytics. Here's the output for ga.js: https://gist.github.com/yahelc/00299f2e4a3c07cafa1a

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

Re: Show HN: Beautify-with-words unminifies JS with unique words for variable names

#22
post #19

Often with AngularJS, after minification, you find you've not properly injected a service or something and looking for a missing 'a' is near impossible. This would be really useful to hunting that down. Would make a great post-min debug Grunt module.

source maps seem more suitable for the job

Re: Show HN: Beautify-with-words unminifies JS with unique words for variable names

#23
post #19

Often with AngularJS, after minification, you find you've not properly injected a service or something and looking for a missing 'a' is near impossible. This would be really useful to hunting that down. Would make a great post-min debug Grunt module.

You might find ngmin[1] helpful for that. Then you can use the shorter injection syntax and have it expanded via a compilation step. Since you mentioned Grunt, you'd probably want to just use grunt-ngmin[2].

[1] https://github.com/btford/ngmin

[2] https://github.com/btford/grunt-ngmin

Re: Show HN: Beautify-with-words unminifies JS with unique words for variable names

#24
post #19

Often with AngularJS, after minification, you find you've not properly injected a service or something and looking for a missing 'a' is near impossible. This would be really useful to hunting that down. Would make a great post-min debug Grunt module.

You might find ngmin[1] helpful for that. Then you can use the shorter injection syntax and have it expanded via a compilation step. Since you mentioned Grunt, you'd probably want to just use grunt-ngmin[2]. [1] https://github.com/btford/ngmin [2] https://github.com/btford/grunt-ngmin

How I never found that.. thanks! That is going to save us a world of pain in debugging.

Re: Show HN: Beautify-with-words unminifies JS with unique words for variable names

#27

While it's a good idea, I feel like it should rename with real words, or not rename at all. From the example: function(bedad, latay, vublu) { if (!adag(this, "on", bedad, [ latay, vublu ]) || !latay) return this; this._events || (this._events = {}); var cyem = this._events[bedad] || (this._events[bedad] = []); bedad, latay and vublu don't make it much easier to remember which variable is which than just using a,b,c

It is a lot easier once you've figured out what a particular variable stands for to do a global search and replace for "vublu" than "a".

Re: Show HN: Beautify-with-words unminifies JS with unique words for variable names

#28

Very cool. Nice work. I think it would be even cooler as a Firefox extension -- open up a .min.js file in one tab, hit your button, and get a new tab with the beautified js. I don't know anything about FF extensions, but since this is written in JS in the first place, it seems doable. (Or alternatively, it would also be cool as a standalone site, just paste the URL or uglified JavaScript in a box, and get the pretty…

I think the way to go would be to create a standalone site and then have a bookmarklet that opens the existing page on that site.

Edit: If you want to use your own bookmarklet, feel free to start off with this: void(open("http://beautifywithwords.com?url=" + location,'_self',''))

Edit2: http://jsbeautifier.org/ has some similarities to this (and integrates with various browsers, editors, etc.) but I don't think it replaces variable names. Perhaps it would make sense to integrate your code into it as an extra feature?

Re: Show HN: Beautify-with-words unminifies JS with unique words for variable names

#29

While it's a good idea, I feel like it should rename with real words, or not rename at all. From the example: function(bedad, latay, vublu) { if (!adag(this, "on", bedad, [ latay, vublu ]) || !latay) return this; this._events || (this._events = {}); var cyem = this._events[bedad] || (this._events[bedad] = []); bedad, latay and vublu don't make it much easier to remember which variable is which than just using a,b,c

I forked the original to address this [1]. Here's a sample: var strategy = moduleInterfaceFactory.Events = { on: function(strategyFacade, strategyFactoryDecorator, interfaceFacade) { if (!flyweight(this, "on", strategyFacade, [ strategyFactoryDecorator, interfaceFacade ]) || !strategyFactoryDecorator) return this; this._events || (this._events = {}); var strategyPattern = this._events[strategyFacade] || (this._events…

Wow, it's like an EnterpriseBridgeAdaptor for JavaScript!

Re: Show HN: Beautify-with-words unminifies JS with unique words for variable names

#30
post #27

While it's a good idea, I feel like it should rename with real words, or not rename at all. From the example: function(bedad, latay, vublu) { if (!adag(this, "on", bedad, [ latay, vublu ]) || !latay) return this; this._events || (this._events = {}); var cyem = this._events[bedad] || (this._events[bedad] = []); bedad, latay and vublu don't make it much easier to remember which variable is which than just using a,b,c

It is a lot easier once you've figured out what a particular variable stands for to do a global search and replace for "vublu" than "a".

That actually makes sense, it is more "grepable" even if it is less easy to reason about. I find it a lot easier to reason about "a" because my brain doesn't try to reason by association -- what could vublu mean, why would they name it vublu?
Post reply on HN