dongpin4611 2013-09-26 14:37
浏览 69
已采纳

解析/解压缩JavaScript

Original Question

This maybe a stupid question but is there a way in VS 2013 to unminify JavaScript?

Just making sure we are all on the same page here.

Minify:

var flashVer=-1;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){var swVer2=navigator.plugins["Shockwave Flash 2.0"]?"

That's just an example to make sure we all know what I'm on about. As far as I can tell there is no way to be able to do this. I have only been using VS 2013 for around 3 weeks so there is probably still stuff that is hidden to me.

If there is no way to do this within the program what is the next best thing for this? I did see on another similar post that recommends the site http://jsbeautifier.org/ , so may have to give that ago but would make life easier if it was built into VS 2013

Thanks in advance as I know someone will be able to help me out here.


Update:

I have looked around VS 2013 and found nothing that can help me with this problem, like I said before they maybe some things I have missed (certain settings) so I guess if it cannot be done in VS what's the next best thing for the job? I seem to run into a fair amount of JS that is minifed and would like the quickest and best way to get the job done. I couple sites I have tried seem to have problems with it, is there a program I could install that would just allow me to short cut it with a hot-key or something. That would be pretty handy.


Update 2:

So I think its safe to say this cannot be done within VS2013, or for that matter at all due to missing var names and so on. So I have seen a few links and programs that allow you to format the code. Is there a way to do with within VS2013? And again if not what is the most reliable website/program that I can use to do this. Like I said I can see there have been answers and I appreciate all of them. I will be leaving this question open for a while to get more people to look at it and possibly give a better answer. Keep it up guys!


Update 3:

If anyone has any more information on this please do share. I am still looking around now and then waiting for someone to come up with something amazing for this. One day people.... One day!

  • 写回答

6条回答 默认 最新

  • dounielong7728 2013-09-29 21:01
    关注

    The thing is that you cannot really "unminify" your code since some data was already lost - e.g. variable names. You can reformat it to more readable form though.

    1. According to this question, since VisualStudio 2012 you can just use <kbd>Ctrl</kbd>+<kbd>E</kbd>, <kbd>D</kbd> keyboard shortcut
    2. If the above is not right, there is this extension for VS 2010: http://visualstudiogallery.msdn.microsoft.com/41a0cc2f-eefd-4342-9fa9-3626855ca22a but I am not sure if it works with VS 2013
    3. There is an extension to VisualStudio called ReSharper which can reformat javascript in a few different manners.
    4. Also there are online formatters already mentioned in other answers (if your code is confidential, I would advise some paranoia manifested by downloading sources and using them locally).
    5. Also you may always try to find unminified version of desired library on the interwebs
    6. Also, there is the WebStorm IDE from JetBrains that is able to reformat JS - you may download a trial for the sole purpose of reformatting your minified scripts :)
    7. If that's just to make debugging easier, you may want to use source maps

    Also, here is a bunch of related questions:

    How to automatically indent source code? <-- this is for VS2010, but it looks promising, maybe it will help you if it supports JavaScript (and it does since VS2012 according to MS support):

    <kbd>Ctrl</kbd>+<kbd>E</kbd>, <kbd>D</kbd> - Format whole doc
    <kbd>Ctrl</kbd>+<kbd>K</kbd>, <kbd>Ctrl</kbd>+<kbd>F</kbd> - Format selection

    reindent(reformat) minimized jquery/javascript file in visual studio

    Visual Studio 2010 can't format complex JavaScript documents

    Visual Studio code formatter

    how to make visual studio javascript formatting work?

    I am not sure if they figured out a working way to reformat JS, but I've seen a few answers which might be helpful - I am just pasting this in here just FYI.

    Added 03.06.2014:

    http://www.jsnice.org/

    This tool could be useful too, it even tries to infer minified names. As stated on their website:

    We will rename variables and parameters to names that we learn from thousands of open source projects.
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog