You can just read 'window.devicePixelRatio' using JavaScript. Retina devices will be more than one.
That's cool, I didn't realize you could use that in production yet but it looks like (other than some weird caveats) you can: http://www.quirksmode.org/blog/archives/2012/07/more_about_d...
I'd love to see a JavaScript library that does this; I've never run across one.