I've been asked to show the results of an image d/b query as a coverflow-y type horizontal scrolling gallery of thumbnails (256px long-side,c. 25kb each). If a library is needed (likely), I'll use jQuery. Besides an image the gallery will likely show some caption (text) data.
Problem is, user's query could unwittingly pull 000s of results. Lazy-loading solves one side, but I can find little on lazy unloading as if the user keeps scrolling the gallery items will only ever grow in number eventually causing the browser to struggle with the amount of data. I figure I need to let the gallery load 10 items, showing the first 5, then lazy add up to X items after which for each item I add I delete the first gallery item. If the user scrolls back down, deleted items need to be lazily re-loaded.
I figure this a problem others must have faced before - even if in a slightly different display context. Would welcome pointers on how to go above the above. Also, in a WAN (web) context are there other performance issues I'm overlooking (e.g. number of gallery items to keep loaded)?
Clarification (in response to answer #1).
Perhaps 'unobtrusive' unload might be a better term. The heart of this is (in a jQuery context) how/where do I place the create/destroy calls?
Assuming the gallery is a scrolling <ul>
(likely horizontal but I guess vertically should be allowed for) showing N <li>
items at a time. The query recordset's offset (zero-based here) can be use to seed an id, e.g. <li id="x_12">
where 12 is the offset value. This should allow code to know for which offset to create/remove and item. It would also make it possible to detect arrival at start (offset 0) whilst AJAX-based loading could incorporate a message mechanism to indicate no next item (i.e. upper end of recordset).
The principle of this, I get. But being less familiar with more complex JavaScript and AJAX I need a nudge as to the practical code detail. My presumption is that if the basic concept works I may well be possible to add-in to existing JQuery based galleries (no point reinventing the wheel there).