Consider the scenario where an image and a text file of the same size, 200 KB, need to be downloaded. The question at hand is: if the image is added to the DOM and the time it takes to load is calculated on `onload`, while simultaneously using Ajax to request the content of the text file, will both actions take the same amount of time? Or would the presence of an image affect the download times?
A recent experiment conducted in a controlled local environment yielded some surprising results.
- Adding an 8MB image to the DOM and measuring the time taken for its download was conducted multiple times (20), ensuring that caching did not skew the results. On average, the image took approximately 4 seconds to download on a local machine.
- In contrast, requesting an 8MB text file using Ajax showed significantly longer download times, averaging around 20 seconds for the textual contents to be retrieved.
The results speak for themselves, but the underlying question remains: why do images and text files exhibit such different download times? Any insights or explanations are welcomed.