不压缩javascript和CSS对客户端处理有什么影响

发布于 2024-11-06 07:34:57 字数 76 浏览 0 评论 0原文

忽略下载时间,让浏览器解释多个单独的小文件而不是一个大文件对性能有何影响。特别是,它会对 ie6 和 7 中的页面渲染速度产生显着影响吗?

Ignoring download times, what's the performance impact of making the browser interpret several separate small files as opposed to one big one. In particular, could it make a significant difference to page rendering speed in ie6 and 7?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

反目相谮 2024-11-13 07:34:57

浏览器通常将自己限制为一定数量的同时请求。这个数字取决于它们的“服务器友好程度”。

允许多少个并发 AJAX (XmlHttpRequest) 请求在流行的浏览器中?

因此,根据浏览器必须加载的工件数量,它可能必须首先等待其他人完成。工件包括浏览器必须返回到服务器的所有内容:图像、javascript、css、flash 等。甚至包括网站图标(如果有的话)。

除此之外,渲染速度通常取决于页面的结构。 IE。您依赖浏览器进行多少次计算(%宽度与固定宽度)。

Browsers typically limit themselves to a certain number of simultaneous requests. This number is dependent on how "server friendly" they are.

How many concurrent AJAX (XmlHttpRequest) requests are allowed in popular browsers?

So, depending on the number of artifacts the browser has to load, it may have to wait for others to complete first. Artifacts include everything the browser has to go back to the server for: images, javascript, css, flash, etc. Even the favicon if you have one.

That aside, rendering speed is normally going to boil down to how the pages are structured. ie. how many calculations you depend on the browser to make (% width vs fixed width).

离去的眼神 2024-11-13 07:34:57

它必须发出更多的往返 HTTP 请求。它可能会也可能不会产生重大后果。

It has to make more round-trip HTTP requests. It may or may not have significant consequences.

拥抱没勇气 2024-11-13 07:34:57

其中,

除了下载时间之外,如果您也有很多 javascript 和 css 文件,则

每个请求都是从客户端到服务器的额外 http 调用。

如果页面加载是主要标准之一,您应该明确考虑它,

也请阅读此文档

http:// /developer.yahoo.com/performance/rules.html

Where,

Apart from download times , if you too have many javascript and css files

Each request is as an extra http call from client to server.

If the page load is one of the main criteria you should definetly think about it

read this doc also

http://developer.yahoo.com/performance/rules.html

一个人练习一个人 2024-11-13 07:34:57

我在一家拥有大型企业 Intranet 的政府组织工作,当我们的 Intranet 门户上加载了大约 25 个以上的 JS 文件和 10 个以上的 CSS 文件时,我们确实注意到 IE6 和 7 中的页面加载时间明显滞后。较新的浏览器具有更快的加载和执行 JavaScript 的例程。我使用 YUI Compressor 来缩小所有内容,包括 CSS。

I work for a gov't organization with a large scale enterprise intranet and when we had around 25+ JS files and 10+ CSS files loading on our intranet portal we did notice a dramatic lag in page load time in IE6 and 7. Newer browsers have faster routines for loading and executing JavaScript. I used YUI Compressor to minify everything including CSS.

辞旧 2024-11-13 07:34:57

如果您在合并文件时包含缩小,那么死代码通常会被删除(取决于压缩器)并且可以优化一些代码(请参阅 YUI 压缩机:什么是微优化?哪个 javascript 缩小库会产生更好的结果? )。

If you include minification in along with combining files, then dead code often gets removed (depending on the minifier) and some code can be optimized (see YUI Compressor: What are micro optimizations? and Which javascript minification library produces better results?).

泛泛之交 2024-11-13 07:34:57

当我第一次开始 Web 开发时,我已经多次问过这个问题。

如果你有少于 10 个 javascript 和 10 个 css 文件(我认为 css 不是那么重要),那么我认为缩小和压缩没有多大用处。但是,如果您正在处理一堆 javascript 文件(超过 10 个),那么是的,它会产生影响。

您可能会遇到的是,即使在压缩、缩小并组合脚本之后,您仍然可能会遇到缓慢的情况。这时 HTML 缓存在网站优化中发挥着巨大的作用,至少我在我的 Web 应用程序中经历过这样的情况。尝试研究 Memcached 并使用它来缓存您的 html 文件。这项技术可以大大加快你的网络应用程序的速度!!!

我假设您的问题与网络优化和高性能网站有关。

只是我的2分钱。

I've asked this question a bunch of times when I first started out with web development.

If you have under 10 javascripts and 10 css files (css not so important in my opinion), then I don't think there is much use minifying and compressing. However, if you are dealing with a bunch of javascript files (greater than 10), then YES, it's gonna make a difference.

What you may experience is, even after compressing and minifying and combining your scripts, you may still experience slow-ness. That's when HTML caching plays a huge role in website optimizations, at least that's what I experienced in my web application. Try looking into Memcached and use it to cache your html files. This technique speeds up your web application a WHOLE LOT!!!

I am assuming your question is related to web optimization and high performance websites.

Just my 2 cents.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文