Last active
August 29, 2015 14:10
-
-
Save joshuaogle/20e90c7a23da08c8a005 to your computer and use it in GitHub Desktop.
Vanilla JS fallback for SVG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| svg_fallback = (function(){ | |
| var supportsSVG = document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1"); | |
| var body = document.querySelector('body'); | |
| var images = document.querySelectorAll("[data-png-fallback]"); | |
| if (!supportsSVG) { | |
| body.className += " no-svg"; | |
| [].forEach.call(images, function(image) { | |
| image.src = image.getAttribute("data-svg-fallback"); | |
| }); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment