html5 - Many images loading performance HTML/Javascript -
ok after searching , not finding real anwser looking came following question in situation:
i have trading website loads 2300 png images of 37x50 twice, once in left column , once in right column. images , information comes inserted using jquery on document on onload event. loading 2300 images (even when html came straight server) takes time , hangs new versions of chrome!. quick solution remove images , show in dynamic tooltip. works great got angry website users , indeed ugly.
so... thought of possible solutions have no idea good/bad practice here:
- make images jpeg , reduce quality.
- with above or not: add images 1 large image, load , draw 4600 canvasses based on locations in array 'imagearray["someimageid"] = { x = 0, y = 40 }'
- convert images base64, add them in array 'imagearray["someimageid"] = "base64"' , draw 4600 canvasses.
and extend must think of of 2300 images have small, medium , large version. (of small ones, 37x40, shown in page)
hope nice insights on how correctly solve such problem!
greets
if images static (not generated every request) think should use css sprites. (similar own suggestion of lots of canvases).
basically create div each image want show (or other container element) , set background on takes small portion of big image contains images.
example css:
img.icon1 { width:50px; height:50px; background:url(spritesheet.png) 50 0; }
in example 50 , 0 indicate offset of 50x50 icon in spritesheet.
update: here http://css-tricks.com/css-sprites/ explanation goes bit further simple example.
Comments
Post a Comment