我想在运行时最小化脚本代码 [英] i want to minimize script Code at a run time

查看:98
本文介绍了我想在运行时最小化脚本代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在每个页面都有jquery脚本代码,我不想公开显示它,所以我希望它最小化安全性和更好的性能。最小化操作应该在浏览器上加载页面时执行。

i have jquery scripting code on every page and i don't want to show it public ,so i want it to minimize for security and better performance .the minimizing action should be perform when page loaded over a browser .

推荐答案

将你的js放在单独的文件中并使用捆绑



http://www.asp.net/mvc/overview/performance/bundling-and-minification [ ^ ]



如果你的js不会进入单独的文件,那么重构它就会这样。
Put your js in separate files and use bundling

http://www.asp.net/mvc/overview/performance/bundling-and-minification[^]

If your js won't go in a separate file then refactor it so it will.


缩小你的资源 - 缩小资源(HTML,CSS和JavaScript) [ ^ ]。

试用什么是JavaScript缩小 [ ^ ]了解虽然文件大小是为了提高性能而压缩的,但公众仍然可以在浏览器中查看这些文件。
Minify your resources - Minify Resources (HTML, CSS, and JavaScript)[^].
Try out what is JavaScript minification[^] to understand that while size of files are compressed for performance, the files will still be available to the public to view in their browser.


除了解决方案1和2之外:



最小化脚本的流量可能是一件好事,但是......请看我对这个问题的评论。它的目的是说服您不要将混淆视为安全措施。它可以被认为是通过默默无闻的安全性之一。如果您认为它非常好并且具有实际意义,那么请再想一想。例如,请阅读:

https://en.wikipedia.org/wiki/Security_through_obscurity [ ^ ]。



至于实际考虑,我不认为你所谓的安全与安全性有关。我宁愿认为你不希望别人窃取你的脚本代码。在这里,我建议考虑它的简单实际后果。如果你的代码非常有价值,所以有些人会非常想要窃取它,你的混淆不能阻止它们,因为你的完整代码总是在客户端,而其他人甚至都不会试图查看它。



-SA
In addition to Solution 1 and 2:

Minimizing the traffic of the scripts can be a good thing, but… Please see my comment to the question. It's purpose is to convince you not to consider obfuscation as a security measure. It can be considered as one of kinds of security through obscurity. If you think it's pretty good and makes practical sense, think again. Read, for example, this:
https://en.wikipedia.org/wiki/Security_through_obscurity[^].

As to the practical considerations, I don't think what you called "security" is really related to security. I would rather think that you don't want others to steal your script code. Here, I would advise to think at simple practical consequences of it. If your code is really valuable so some people would badly want to steal it, your obfuscation cannot stop them, because your full code will always be on the client side, and other people won't even try to look at it.

—SA


这篇关于我想在运行时最小化脚本代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆