Programmer
Programmer

Reputation: 8697

Online JS editor to diplay JS code in readable format

On trying to debug an issue via FireBug in FF I landed up to a JS that runs hundred lines with no new lines, space and indentation. Though I know JS a little bit but reading this JS code was piratically impossible.

Math.random().toString().replace(/90\./,"");this.res=[];this.req=[];this.ret=null;this.retry=true;this.timeout=null;this.getDuration=function(precision){precision=!isNaN(precision)?(3-precision):0;};..........................and so on non-stop....

Is there a way in FireBug or via an online tool to make this JS code format into proper human readable format?

Upvotes: 0

Views: 210

Answers (2)

Frank van Puffelen
Frank van Puffelen

Reputation: 598718

What you're seeing is obfuscated/minified JavaScript code.

This is done as a pre-production step to reduce download size of the script for web site visitors.

Your options to work with something more readable are (in order of ease of use):

  1. if you have access to the original JavaScript files and can modify the web site, that is you best bet
  2. if you have access to the source maps ( http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/ ), you can tell the browser to use those
  3. run an offline beautifier as @AlexMihai suggests

Upvotes: 0

user1703809
user1703809

Reputation:

Try jsBeautifier. It's a pretty cool tool and is web based, so no download required.

You can also find a list of browser extension downloads if you wish.

Upvotes: 0

Related Questions