Technically, it could be one HTTP request. He could convert the image data to base64 and use a data uri.
That won't work with all browsers. See http://caniuse.com/datauri. (Don't think that people have stopped using ancient IEs. And don't think that the browsers listed there are ALL browsers that exist.) Plus, it wastes a lot of bandwitdh, especially if the image is static. Using a classic HTTP(S) URL for the image allows the browser and all proxies between browser and server to cache the image, so it is transmitted only once, whereas the data URL "solution" sends the image for every request, with an additional overhead of 33% due to base64 encoding.
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
| [reply] |
>That won't work with all browsers.
Well, for that matter, his choice of png images won't work on all browsers either. You have to draw a line somewhere :)
>Plus, it wastes a lot of bandwitdh, especially if the image is static
The code seems to indicate the image is a dynamic representation of current weather conditions that may not make sense to cache.
But yes, I concede that data uris do have drawbacks.
| [reply] |