2

I am new to JavaScript and came across this practice of minimizing javascript files. I however couldn't find any tool Online or in VS code which could maximize my js code using an attached source file.

Here are the files that I have
a.js:

webpackJsonp([1],{681:function(... One line code
//# sourceMappingURL=a.js.map

a.js.map:

{"version":3,"file":"a.js",... 

Which Online or VS Code tool can I use to unuglify my code?

Background:
I've tried uglify-js in the terminal

loc/to/uglifyjs/binary a.js -b --source-map a.js.map -o a_unuglified.js

I got an error saying a.js.map is not a supported map. I've also tried using VS code plugins but none of them seem to work.

EDIT
The following worked:
1) loc/to/uglifyjs/binary a.js -b -o a_unuglified.js --source-map "filename='a.js.map'"
2) Using developer tools as Jon suggested

However, the unuglified code still had unknown symbols and variable names. I looked around and realized that that it is equivalent to compressed binary code and that it would be near impossible to get the original code. That compelled me to look for the source code which I instantly found.

TLDR
Look for original source code if you have that option instead of trying to unuglyfy.

2 Answers2

3

Just an update to this question, the uglify-js API changed a little. Currently, it'd be something like:

npx uglify-js ugly.js -b --source-map "filename='ugly.js.map'" -o beauty.js
matheusr
  • 567
  • 9
  • 29
1

Take a look at https://developers.google.com/web/tools/chrome-devtools/javascript/reference#format. So, if you can load your code into the Chrome browser, you can make a minified JS file readable via the Developer Tools, and copy/paste from there...

(Quick edit... In fact, take a look at https://stackoverflow.com/a/36554691/7696162, as I think that answers your question.)

Trentium
  • 3,419
  • 2
  • 12
  • 19
  • How do I open the java script file in Google chrome to inspect the source? It opens as a text file if I open directly. – Krishna Toshniwal May 05 '19 at 23:29
  • With the web page that uses a.js / a.js.map, or creating a simple HTML page referencing a.js (per the stackoverflow reference above), open this page in Chrome and then open up developer tools. – Trentium May 07 '19 at 12:57