Skip to content

Instantly share code, notes, and snippets.

@ryanburgess
Last active October 19, 2015 09:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanburgess/9835ab8b42002df63846 to your computer and use it in GitHub Desktop.
Save ryanburgess/9835ab8b42002df63846 to your computer and use it in GitHub Desktop.
Determines whether or not the given browser supports SVG

If SVG

Is a simple JavaScript module that determines whether or not the given browser supports SVG.

Install

npm install if-svg --save-dev

Use

var isSVG = require('is-svg');
if(isSVG()){
  // do something
}
// ifSVG
//
// Use: Determines whether or not the given browser supports SVG
//
// Returns: Boolean
// ------------------------------------------------------------
module.exports = function ifSVG(){
if (!document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1')) {
return false;
}else{
return true;
}
}
{
"name": "if-svg",
"version": "1.0.3",
"description": "Determines whether or not the given browser supports SVG.",
"main": "if-svg.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"homepage": "https://gist.github.com/ryanburgess/9835ab8b42002df63846",
"repository": {
"type": "git",
"url": "https://gist.github.com/9835ab8b42002df63846.git"
},
"keywords": [
"svg",
"javascript",
"browser",
"detect",
"check",
"images"
],
"author": "Ryan Burgess <rburgess@evernote.com> (http://everernote.com/)",
"license": "MIT"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment