什么是速度更快,为什么? [英] What is faster and why?

查看:106
本文介绍了什么是速度更快,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关可维护性的原因,我想数据库驱动器我的javascript,因为我只是想送它是基于用户选择所需的JavaScript。

那么,是不是更快/较少的资源重于在数据库中有指向JavaScript文件,然后使用response.writefile对这些文件嵌入到客户方的网页链接,或者是更快/资源重贴的JavaScript脚本少直入数据库,并RESPONSE.WRITE它在屏幕上的时候需要?


解决方案

  

那么,是不是更快/较少的资源重于在数据库中有指向JavaScript文件的链接


通常是的。

外部JavaScript文件可以被浏览器高速缓存,并且将仅加载一次。的JavaScript code注入到HTML页面需要每一次,这增加了带宽和加载时间被加载

另外,有一个静态文件(而不是一个动态的从数据库中获取的code在每次请求)的JavaScript code注定是最快和最耗费资源的解决方案。

For maintainability reasons, I want to database drive my javascript, in that I only want to send the javascript which is needed based on the users options.

So, is it faster/less resource heavy to have links in the database pointing to javascript files, then using response.writefile to embed those files into the clientside page, or is it faster/less resource heavy to stick the javascript script straight into the database, and response.write it onto the screen as and when needed?

解决方案

So, is it faster/less resource heavy to have links in the database pointing to javascript files

Usually yes.

External Javascript files can be cached by the browser, and will be loaded only once. Javascript code injected into the HTML page needs to be loaded every time, which increases bandwidth and loading times.

Also, having JavaScript code in a static file (instead of a dynamic one that fetches the code from the database on every request) is bound to be the fastest and least resource-intensive solution.

这篇关于什么是速度更快,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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