chrisben/imgcache.js — pull request #21 by coobstar (2013-11-05 19:37:57+00:00)
Title: Avoid forcing img load from src attribute while retrieving cache.

As it was before, only the element to be filled with the cached image could be passed to useCachedFile. The src value was then extracted from the element itself.

However, this defeats the purpose of loading an image from cache, namely, that one may avoid making a network transaction. If the element passed in already has a 'src' attribute (which it must in the previous implementation), the browser has already initiated the call to load that url.

To amend this issue, useCachedFile now accepts two parameters, the element and the image url. Now the img element will not attempt to load the url via network call before retrieving the image from the cache. Of course, if you still wish to use the previous functionality, simply extract the src from the element in your function call.