开发者

adding image to dom and requesting content of txt file using Ajax. does it take same time?

I have image and txt file of same size say 200 KB. Now i would like to calculate the time to download the image and text of text file.

Now my question is adding image to DOM and and then calculating time on onload and requesting content of txt file using Ajax will they take same time or due to image and xml they will take different time ? why ?

Hi i have run a small experiment on the local machine and results are surprising. Experiment environment

  1. add 8MB image to DOM and calculate time for its download i tried this for 20 times making sure tha开发者_如何学Got the image is not getting cached. I found that on local machine it takes around 4 seconds.
  2. 8 MB text file is requested using the AJAX and i found that it takes around 20 sec to download the textual contents

The think is clear from the experiment but question is still there why ? can any one help on this.


I've never actually tested it, but the transport portion should take the same amount of time. There might be a bit more overhead involved in the image as it involves a bit of reflow on load, firing events, that sort of thing, but I wouldn't think you'd be able to notice the difference.

Beyond that, we start getting into network topology and optimization stuff, like are any of the links making use of on-the-fly point to point encryption and if so, do they transfer the text file faster because it compresses better, that sort of thing. But that way lies madness, if you're talking about figuring this out across a heterogenous network (say, like the internet).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜