Skip to content

Instantly share code, notes, and snippets.

@joshuaogle
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save joshuaogle/20e90c7a23da08c8a005 to your computer and use it in GitHub Desktop.

Select an option

Save joshuaogle/20e90c7a23da08c8a005 to your computer and use it in GitHub Desktop.
Vanilla JS fallback for SVG
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