Saturday, March 24, 2012

Un-minify JS, CSS or HTML

I've just found this cool resource for turning minified JS or HTML back into readable source code.

http://jsbeautifier.org/

To illustrate what I mean, the following code is the content of Evernote's bookmarklet.

javascript:(function(){EN_CLIP_HOST='http://www.evernote.com';try{var%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=EN_CLIP_HOST+'/public/bookmarkClipper.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')[0].appendChild(x);}catch(e){location.href=EN_CLIP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);}})();


Running it through JS Beautifier results in


javascript: (function () {
    EN_CLIP_HOST = 'http://www.evernote.com';
    try {
        var x = document.createElement('SCRIPT');
        x.type = 'text/javascript';
        x.src = EN_CLIP_HOST '/public/bookmarkClipper.js?' (new Date().getTime() / 100000);
        document.getElementsByTagName('head')[0].appendChild(x);
    } catch (e) {
        location.href = EN_CLIP_HOST '/clip.action?url='
        encodeURIComponent(location.href)'&title='
        encodeURIComponent(document.title);
    }
})();


Nice!

4 comments:

  1. I tried it and it worked quite well. Thank you!

    ReplyDelete
  2. Great tool. Helped me out. Thanks for posting!

    ReplyDelete
  3. Brilliant article. Exceptionally fascinating to peruse. I truly love to peruse such a pleasant article. Much appreciated! continue shaking.
    css beautifier

    ReplyDelete
  4. I have been reading you blog for a few days, very good job! Aerospace webdesign

    ReplyDelete

Note: Only a member of this blog may post a comment.