内嵌JavaScript来提高性能 [英] Increasing performace writing javascript inline

查看:108
本文介绍了内嵌JavaScript来提高性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生

我必须写JavaScript验证属于任何控件
我应该在哪里写


1)在控制之下的源代码中,通过写入< script></script>每个控件的标签都不同

2)用相同的源代码编写验证,但只创建一个标签< script></script>一次控制所有


3)通过编写单独的JavaScript文件并包括.js文件


告诉我哪个最好
以page

Sir

I have to write JavaScript validation belong t any control
where should i write


1) in source code below the control by writing <script></script> tag for each control differentially

2) writing validation in same source code but creating only one tag <script></script> for all control at once


3) by writing separate JavaScript file and by including .js file


tell me which best
in form of performance of page

推荐答案

Well的性能形式,这取决于JS代码的数量.

一般而言:
通过编写单独的JavaScript文件并包含.js文件
此选项将使您获得良好的性能,因为它是一个外部文件,一旦下载到客户端,就可以缓存并多次使用.会减少响应的大小和时间.
这种方法还有助于维护性和部署/交付.


如果您的JS代码非常小,几乎没有警报,那么也可以内联完成.
Well, it would depend on amount of JS code.

In general:
by writing separate JavaScript file and by including .js file
This option would let you to a good performance as it would be an external file which once downloaded on client can be cached and used multiple times. Would reduce the response size and time.
This approach also helps in maintainability and deployment/delivery.


If you have very small JS code, kind of few alerts or so then it can also be done inline.


Sandeep M.已经非常有效地描述了,您仍然可以浏览以下链接:
将JavaScript与ASP.NET一起使用
Sandeep M. already described very efficiently, still you can navigate the following link:
Using JavaScript Along with ASP.NET


这篇关于内嵌JavaScript来提高性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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