SVG polyfill in pure Javascript

A designer at work pointed out this SVG polyfill as a candidate for our new production site. While I like the elegance of it, I was a bit disappointed that the author felt the need to include jQuery as a dependency simply to use its selector engine and each function. So, I rewrote it in pure Javascript.

Javascript:

1
2
3
4
5
6
7
if(!(!!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect)){  
    var imgs = document.getElementsByTagName('img');

    for(var i = 0; i < imgs.length; i++) {  
        imgs[i].setAttribute('src', imgs[i].getAttribute('src').replace(/\.svg/, '.png'));  
    }  
}

Comments !