如何从缩小的 javascript 文件获取源代码?
我使用在线 YUI 压缩器来缩小我的 javascript 文件...现在我得到了它的缩小版本,但我丢失了源代码,因为我上传了源 javascript 文件而没有复制它...
- 我如何从缩小的 javascript 中获取源代码文件?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您必须努力工作,但作为起点,我建议您重新格式化并重新缩进代码,有一些工具可以做到这一点:
正如我所说,这将为您提供一个起点,您需要充分了解代码才能正确重命名变量和函数。
最后一个选择是考虑重写,如果您确切地知道脚本的用途,则可以比重构缩小的源代码花费更少的时间...
最后但并非最不重要的一点是我会建议您始终使用版本控制系统并经常进行备份...
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:
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...
缩小后的JS文件实际上就是源代码。它只是高度混乱。
例如,您可以将此文件加载到 Aptana 编辑器中,然后按 ctrl+shift+f 来格式化源。或者使用任何其他源代码格式化程序。
您将恢复代码结构,但变量/函数/属性名称将永远丢失。
惨痛的教训:)
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 :)
我已经使用了前面提到的
,但我发现开发人员工具中内置的 Chrome Pretty 打印功能是最一致的。
它位于“脚本”选项卡下的图标菜单中,旁边有“调试时暂停”、“显示/隐藏控制台”和“窗口对接”
I've used both the aforementioned
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