Skip to content

Instantly share code, notes, and snippets.

@ingozoell
Created March 13, 2017 11:59
Show Gist options
  • Save ingozoell/45b98ed652c5e1656f4c24c31b36d0d6 to your computer and use it in GitHub Desktop.
Save ingozoell/45b98ed652c5e1656f4c24c31b36d0d6 to your computer and use it in GitHub Desktop.
SVG Check/ Fallback without jQuery and Modernizr
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