Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PNG-Fallback for SVG-Images. Inspired by http://codepad.co/s/02aac9, but realized without jQuery-Dependency. Only Modernizr is needed.
var rSvg = /\.(svg)$/;
if ( !Modernizr.svg ) {
for ( var i = 0, img; img = document.images[i]; i +=1 ) {
if ( !rSvg.test(img.src) ) continue;
img.src = img.src.replace(rSvg, '.png');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment