How to Unminify Javascript Code

Programming Tips

As websites have moved away from static pages to interactive updating displays, the modern Greasemonkey hacker has been forced to learn new tricks: namely interacting with the Javascript on a website. Sometimes that’s harder than it looks because the Javascript on the site you want to modify has been minified.

Minifying is a process where all the comments, whitespace and variable names of a file are removed so that it is smaller in size. This is better for the users because it takes less time to load the site. It’s worse for Greasemonkey hackers because all you get is a mess of gobblety gook.

  1. Install this javascript beautifier Greasemonkey script
  2. Cut-and-paste the minified javascript from the site you want to work with
  3. Visit nopaste.voric.com and cut-and-paste the code from the site
    1. Click the Javascript option
    2. Change “Save until” to 1 day
    3. Cut and paste the code from the site
    4. Click “Save”
  4. Click the Beautify link

Now you have a copy of the source code you can work with! I usually save it to a local file at this point so that I can annotate it with comments.

There are probably simpler ways to do this with other javascript beautifiers, but I haven’t found any other ones that do as good of a job at deminifying code as this trick.

2 Comments

  1. Posted May 02, 2008 at | Permalink

    Interesting trick, glad I found it.

  2. Posted May 13, 2008 at | Permalink

    it’s all greek to me. but the friendfeed image reminded me, the friendfeed feed doesn’t display properly in wordpress.com. do you know of a trick to get it working? if you do, please share. thanks in advance! :D

One Trackback

  1. [...] How to Unminify Javascript Code [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*