Check for retina via javascript

Retina displays can lead to all sorts of new things you can do, some of them headache–inducing. Detecting for retina devices or hi–density displays still isn’t a straightforward thing, but this javascript snippet could come handy for a quick hack:

if((window.devicePixelRatio===undefined?1:window.devicePixelRatio)>1)
    // do something here

More details on this technique from Shaun Inman’s post.