Skip to content

Instantly share code, notes, and snippets.

@aalexeev239
Last active September 17, 2015 23:10
Show Gist options
  • Save aalexeev239/18932c97263c0edfc7cc to your computer and use it in GitHub Desktop.
Save aalexeev239/18932c97263c0edfc7cc to your computer and use it in GitHub Desktop.
prevent image loading for mobile
<!--The idea is to load base64-encoded 1px transparent gif for some media queries-->
<picture>
<source media="(max-width: 759px)" srcset="data:image/gifbase64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==">
<img src="image.png" srcset="image@2x.png 2x, image@3x.png 3x" height="100" width="100" alt="image">
</picture>
<picture>
<source srcset="{{img}}" media="(min-width: 768px)" />
<img srcset="data:image/gifbase64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="{{title}}" width="110" height="110" />
</picture>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment