I've been trying to find a good approach to solve a very commmon problem in the retina era.
Lets say the following is given:
- Create a website with responsive images
- No CSS background images
- Websites basic functionality must be working without JS
- The websites images must be optimized for retina displays.
An easy way to solve this could be something like this:
<img src="img.jpg" data-highres="img@2x.jpg" />
and write some kind of js to swap out img.jpg with img@2x.jpg if retina device is detected. This would work, but if I enter the website on a retina device both img.jpg and img@2x.jpg would be loaded. Not very bandwidth friendly :(
Is it possible somehow to intercept and change the src of the image before the original src is loaded?
Or do any of you have another approach in solving the problem?