[OpenLayers-Dev] Loading img with Ajax to be able to cancel loading?

Tim-Hinnerk Heuer th.heuer at gmail.com
Mon Mar 19 00:48:44 EDT 2012


Just wondering here how one could optimize the img loading of OpenLayers:

Would it be possible to load img srces with ajax and then assign the .src
attribute on the <img/> element? That way it would be possible to cancel
the loading of an img before it gets added to the dom and only render and
therefore finish loading it if the user does not pan away from it.

Not sure if this is already happening, because I haven't checked, sorry.

I was stress-testing our applications with Chrome's profiler and the set
src function was a significant candidate for optimization, because it
seemed to be one of the heavier used functions up there with the anonymous
function call inside the Util.bind function.

Also, I noticed that if one zooms and pans about a lot, after a while one
gets white tiles and it seems like things are broken. Waiting for quite a
bit revealed that the requests must have been running in the background and
when they were finished the imgs were displayed. If we can cancel the img
loads that are not within the current extent, we would probably save a lot
of WMS requests to the server.

Does this sound sensible?


++Tim Hinnerk Heuer++

Twitter: @timhheuer
Blog: http://www.thheuer.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20120319/2de840e8/attachment.html

More information about the Dev mailing list