Created
March 13, 2017 11:59
-
-
Save ingozoell/45b98ed652c5e1656f4c24c31b36d0d6 to your computer and use it in GitHub Desktop.
SVG Check/ Fallback without jQuery and Modernizr
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
if (!Modernizr.svg) { | |
var imgs = document.getElementsByTagName('img'); | |
var endsWithDotSvg = /.*\.svg$/ | |
var i = 0; | |
var l = imgs.length; | |
for(; i != l; ++i) { | |
if(imgs[i].src.match(endsWithDotSvg)) { | |
imgs[i].src = imgs[i].src.slice(0, -3) + 'png'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment