如何在asp.net中优化javascript加载 [英] how to optimise javascript loading in asp.net

查看:68
本文介绍了如何在asp.net中优化javascript加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你很高兴,



你能给我/帮我加载asp.net / mvc中的javascript。



如果javascript依赖于其他两个javascripts。



如果它们是大脚本,加载javascript的最佳方式是什么。



谢谢

Hi frends,

can you give / help me in loading a javascript in asp.net /mvc.

if the javascript depends on 2 other javascripts.

if they are big scripts, what is the best way to load javascript.

thanks

推荐答案

这个问题没有意义:你没有加载你的JavaScripts来增强任何东西,你的客户端的浏览器从服务器下载所有资源并执行脚本。



我怀疑你的问题是非常大的脚本,但只有你学习更好的编程才能改进它。你只需要提高你的编程技巧,就可以编写更少更快更好的代码。



只有这一点,你可以做一些技巧,帮助你减少脚本的大小。 (同样,它与加载无关;你只是可以减少网络流量,这是真正的瓶颈。如果你有非常大的文件,它可以得到回报。)为此,你可以将脚本编译成其他脚本这是压缩但可能纯粹可读。 Google Closure Compiler的一个例子是:

https://developers.google.com/closure/编译器 [ ^ ],

https://closure-compiler.appspot.com/home [ ^ ]。



你可以找到更多: http://bfy.tw/CRn [ ^ ]。



-SA
The question makes little sense: you are not "loading" your JavaScripts to enhance anything, your client's browser downloads all resource from the server and executed the scripts.

I doubt that your problem is great sized of the scripts, but you can improve it only if you learn better programming. You just need to improve your programming skills to write less code which does more and faster.

Only on top of that, you can do some technical tricks that helps you to reduce the size of the scripts. (Again, it has nothing to do with "loading"; you just can reduce the network traffic, which is the real bottleneck. It can pay off if you have really big files.) For that purpose, you can compile script into other script which is compressed but perhaps purely readable. One example of such thing is Google Closure Compiler:
https://developers.google.com/closure/compiler[^],
https://closure-compiler.appspot.com/home[^].

You can find a lot more: http://bfy.tw/CRn[^].

—SA


这篇关于如何在asp.net中优化javascript加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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