javascript - Optimizing online photo gallery for retina devices -


i have existing website (a photo blog) loads majority of photos flickr. i'd enhance experience users high resolution screens , load higher res versions of photos, i'm not sure best way go.

since images in question not ui elements, there no sensible way solve problem css. leaves either client side javascript, or server side find-and-replace specific image patterns (since come flickr, it's easy detect , easy enough figure out url double-sized image).

for client side, concern regular sized images 500-800 kb in size, there there can 10-30 images per gallery, causing lots of excess bandwidth use retina users.

for server side, it's tricky determine if request comes retina device or not. 1 idea had (which have yet test out), run javascript function checks window.devicepixelratio , sets cookie accordingly, , on each successive page request server know if device high res or not. leaves entry page non-retina images, @ least next ones have high res images loaded right away.

are there pitfalls proposed solution? there better ways handle it?

you can generate css on server have links both regular size , double-sized images in background-image property. css can different every page including in <style> tag , referencing classes/ids exist on page. deal traffic issue, since majority of modern browsers don't load pictures other dpis.

other solution (though worse) not set cookie, load images javascript. solve initial first page issue, slow down page rendering little.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -