Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PNG-Fallback for SVG-Images. Inspired by, 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