DOMContentLoaded / load(event),如何提高速度。(DOMContentLoaded/load (event), how to increase the speed.)

编程入门 行业动态 更新时间:2024-10-27 22:24:08
DOMContentLoaded / load(event),如何提高速度。(DOMContentLoaded/load (event), how to increase the speed.)

我正在尝试尽我所能来提高页面的加载速度,特别是加载ajax的组件。

在萤火虫中,我的出局看起来像这样

我不完全确定我是否正确读取它,但对于DOMContentLoaded它是+ 2.19s(或者如果我们应该从等待响应中减去它,它可能只有.8)。

但是然后4.67s为'负载'(事件)。

这两者似乎都是非常长的加载时间。

我无法弄清楚会导致这种情况的原因。 这些统计数据来自加载一个直接的html页面,我通常通过ajax加载。 但这只是HTML。 页面中没有javascript,页面正在直接加载,而不是通过ajax请求。

但是,当我通过ajax加载此页面时,我发现页面尝试加载时会出现严重延迟。

有什么建议么?

我一直在浏览IE调试栏中的html,它看起来都非常干净。 页面中有30个图像。 这可能是'加载'事件在等待什么? 如果是这样,有什么方法可以加快速度吗?

特别是,由于用户永远不会直接加载此页面,而只是通过ajax请求,这是他们提高ajax中页面加载性能的方法。 问题不在于ajax加载脚本,而是具体使用html页面。

---------------------- EDITTED --------------------------- ---页面的结果被加载到一个jquery循环中,其中一次可以看到多个图像,因此使用lazyloader提供了非常糟糕的用户体验。 (假设是导致此问题的图像)。

I'm trying to do everything I can to increase the load speed of my pages, and in particular the ajax loaded components.

In firebug, my out put looks like this

I'm not entirely sure if I'm reading this correctly, but it is either +2.19s for DOMContentLoaded (or it mayonly be .8 if we are supposed to subtrack that from the waiting response).

But then 4.67s for the 'load' (event).

Both of these seem like significantly long loading times.

I haven't been able to figure out what would cause these sorts of times. These stats are from loading a straight html page which I normally load via ajax. But this is just the HTML. No javascript in the page, and the page is being loaded directly, not through an ajax request.

However when i do load this page via ajax, I recognize a significant delay while the page attempts to load.

Any suggestions?

I've been looking through the html in IE debugbar, and it all looks surprisingly clean. There are 30 images in the page. Could that be what the 'load' event is waiting for? And if so, is there any way to speed this up?

In particular, as the user will never load this page directly, but only via an ajax request, is their a way to improve the page loading performance in ajax. The problem isn't with the ajax loading script, but with the html page specifically.

----------------------EDITTED------------------------------ The results of the page are loaded into a jquery cycle where multiple images are visible at a single time, so using lazyloader provides a pretty horrible user experience. (assuming it is the images which is causing this problem).

最满意答案

那些萤火虫的统计信息告诉你:

从您开始请求服务器端代码开始返回响应开始,需要2.1秒 然后下载响应需要19ms(即HTML) 71ms左右之后,DOMContentLoaded事件触发 页面完全加载后(图​​像全部下载完毕后),将触发加载事件。

一旦DOM准备好,DOMContentLoaded就会触发。 加载事件等待,直到加载整个页面(包括任何外部资源,如图像)

您的请求中的大部分时间(除了下载图像)都花在等待服务器构建HTML上。 也许你的服务器端代码可以优化运行得更快?

Those firebug stats are telling you that:

It takes 2.1 seconds from the time you started the request for your server-side code to start returning a response It then takes 19ms to download the response (i.e. the HTML) 71ms or so after that, the DOMContentLoaded event fires After the page has completely loaded (after the images are all downloaded), the load event is fired.

DOMContentLoaded fires as soon as the DOM is ready. The load event waits until the whole page is loaded (including any external resources like images)

Most of the time in your request (other than downloading the images) is spent waiting for the server to construct the HTML. Maybe your server-side code can be optimized to run faster?

更多推荐

本文发布于:2023-08-02 07:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1370046.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:速度   load   DOMContentLoaded   event   speed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!