FYI - the same functionality is available in IE9's F12 Developer Tools: With script tab open, select the hammer/wrench button on the button bar ("Configuration"), and select "Format JavaScript".
If the script is only minified for whitespace, some of the solutions offered may work. As you mention, JSBeautifier is a useful tool.
However, if the JavaScript you're looking at has been compressed with a tool such as YUI Compressor or Google Closure Compiler, the variables are going to be shortened and harder to understand.
To see this in action, compare the minified and unminified versions of jQuery (minified version uses Closure Compiler).
For the goal of learning JavaScript, I recommend learning from libraries and plugins written by some of the best JavaScript developers out there. Look at the source code for jQuery, YUI, Moo Tools. Look at code on GitHub by people like John Resig or Thomas Fuchs. Read DailyJs and look at his examples.
I hope some of these tools help you in the process of learning. These are the resources that have helped me most.
Is not possible with current tools. Show eval scripts is the most you can get.
Jsbeautifier.org is nice open thing, and someone can integrate it info firebug.
发布评论
评论(9)
有人将 JSBeautifier 制作成了 Firebug 插件:
https://addons.mozilla.org/en- US/firefox/addon/javascript-deminifier/
这让我今天很开心!
Someone has made JSBeautifier into a Firebug plugin:
https://addons.mozilla.org/en-US/firefox/addon/javascript-deminifier/
This has made my day today!
在 chrome 13+ 中,有“漂亮的打印”。
In chrome 13+, there is 'pretty print'.
Venkman JavaScript 调试器有一个漂亮的打印机。
还有一个用于 Fiddler 代理的扩展。
IE9 开发人员工具还具有“格式化 javascript”选项(请参阅“F12 开发人员工具和格式化缩小脚本”此处)
Venkman JavaScript debugger has a pretty-printer.
There is also an extension for Fiddler proxy.
IE9 developer tools also have a "format javascript" option (see "F12 Developer Tools and Formatting Minified Script" here)
仅供参考 - IE9 的 F12 开发人员工具中提供了相同的功能:打开脚本选项卡,选择按钮栏上的锤子/扳手按钮(“配置”),然后选择“格式化 JavaScript”。
FYI - the same functionality is available in IE9's F12 Developer Tools: With script tab open, select the hammer/wrench button on the button bar ("Configuration"), and select "Format JavaScript".
如果脚本仅针对空白进行缩小,则提供的某些解决方案可能会起作用。正如您提到的,JSBeautifier 是一个有用的工具。
但是,如果您正在查看的 JavaScript 已使用 YUI Compressor 等工具进行压缩或 Google Closure 编译器,变量将会被缩短并且更难理解。
要查看其实际效果,请比较 jQuery 的缩小版本和未缩小版本(缩小版本使用 Closure Compiler)。
为了学习 JavaScript,我建议学习一些由一些人编写的库和插件最好的 JavaScript 开发人员。查看 jQuery 的源代码,YUI、Moo 工具。查看 GitHub 上由 John Resig</a> 或 托马斯·福克斯。阅读 DailyJs 并查看他的示例。
我希望其中一些工具对您的学习过程有所帮助。这些是对我帮助最大的资源。
If the script is only minified for whitespace, some of the solutions offered may work. As you mention, JSBeautifier is a useful tool.
However, if the JavaScript you're looking at has been compressed with a tool such as YUI Compressor or Google Closure Compiler, the variables are going to be shortened and harder to understand.
To see this in action, compare the minified and unminified versions of jQuery (minified version uses Closure Compiler).
For the goal of learning JavaScript, I recommend learning from libraries and plugins written by some of the best JavaScript developers out there. Look at the source code for jQuery, YUI, Moo Tools. Look at code on GitHub by people like John Resig or Thomas Fuchs. Read DailyJs and look at his examples.
I hope some of these tools help you in the process of learning. These are the resources that have helped me most.
Webkit/Chromium 现在也可以执行此操作,请参阅 Webkit Bug 57942、变更集 83713 和 Peter Beverloo 的更改摘要帖子提到了这一点。
不要问我从哪个版本的 Chromium/Chrome 开始可用,但如果您确实知道,请随时在此处提及。 :)
Webkit/Chromium can now do this as well, see Webkit Bug 57942, Changeset 83713 and Peter Beverloo's change summary post mentioning this.
Don't ask me starting with which version of Chromium/Chrome this is available, but feel free to mention here if you do know. :)
Firefox Firefox 开发者工具的“自动美化缩小源代码”设置可通过以下方式打开美化源代码功能默认。
要启用它:
这是记录的位于: https://developer.mozilla.org/ en-US/docs/Tools/Debugger/How_to/Pretty-print_a_minified_file
在 Firefox 42 上测试。
"Auto Prettify Minified Sources" setting of Firefox Firefox Developer Tools turns the Prettify Source feature on by default.
To enable it:
This is documented at: https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Pretty-print_a_minified_file
Tested on Firefox 42.
使用当前工具是不可能的。显示评估脚本是您可以获得的最多的。
Jsbeautifier.org 是一个很好的开放东西,有人可以将它集成到 firebug 信息中。
Is not possible with current tools. Show eval scripts is the most you can get.
Jsbeautifier.org is nice open thing, and someone can integrate it info firebug.
PrettyPrint 是一个很好的 chrome 扩展,它在使用常规 (Ctrl-U) 源时自动立即取消压缩 js。
您可以在此处获取:
https://chrome.google.com/webstore/detail/ Prettyprint/nipdlgebaanapcphbcidpmmmkcecpkhg/
PrettyPrint is a nice chrome extension for this, it automatically unminifies js in a heartbeat while using regular (Ctrl-U) source.
You can get it here:
https://chrome.google.com/webstore/detail/prettyprint/nipdlgebaanapcphbcidpmmmkcecpkhg/