最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

minify - How can i get source from a minified javascript file? - Stack Overflow

programmeradmin4浏览0评论

I used online YUI Compressor for minifying my javascript file... Now i got minified version of it but i lost the source as i uploaded the source javascript file without taking a copy of it...

  • How can i get source from a minified javascript file?

I used online YUI Compressor for minifying my javascript file... Now i got minified version of it but i lost the source as i uploaded the source javascript file without taking a copy of it...

  • How can i get source from a minified javascript file?
Share Improve this question asked Jan 30, 2010 at 4:40 ACPACP 35.3k101 gold badges233 silver badges373 bronze badges 0
Add a comment  | 

4 Answers 4

Reset to default 13

You will have to work hard, but as a starting point I would recommend you to reformat and reindent the code, there are out there some tools to do it:

  • JavaScript unpacker and beautifier
  • JavaScript Beautifier

That as I said, will give you a starting point, you will need to know the code well to rename your variables and functions properly.

The last option would be to consider a rewrite, which if you know exactly what your script is meant to do, can take less time than refactoring the minified source...

And at last but not least I would recommend you to work always with a version control system and do backups often...

Minified JS file is the source code in fact. It's just highly obfuscated. You can, for example, load this file into Aptana editor and hit ctrl+shift+f to format the source. Or use any other source code formater.

You will get your code structure back, but the variable/function/property names are lost forever.

Hard lesson :)

I've used both the aforementioned

  • JavaScript unpacker and beautifier
  • JavaScript Beautifier

but i find the built-in Chrome Pretty print function in the Developer Tools to have been the the most consistent.

it's under the Scripts tab, in the icon menu alongside Pause on debug, Show/hide console, and Window docking

Here is an example where the referenced file is a minified file and automagically transformed into something legible:

http://prettydiff.com/?m=beautify&s=http://prettydiff.com/prettydiff.js

发布评论

评论列表(0)

  1. 暂无评论