Created
July 29, 2012 19:50
-
-
Save madrobby/3201472 to your computer and use it in GitHub Desktop.
Check if the browsers supports SVG
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
// comments welcome, there may be better ways to do this! | |
function supportsSVG(){ | |
return !!('createElementNS' in document && | |
document.createElementNS('http://www.w3.org/2000/svg','svg').createSVGRect) | |
} |
You can crunch this down a bit to be
function supportsSVG(a,b){return !!((b='createElementNS') in (a=document) && a[b]('http://www.w3.org/2000/svg','svg').createSVGRect)}
Which saves 9 bytes - if that's what you want.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm looking for an as-short-as-possible snippet that reliably detects support for SVG.