Skip to content

Instantly share code, notes, and snippets.

@rutger1140
Created April 5, 2014 16:05
Show Gist options
  • Save rutger1140/9993776 to your computer and use it in GitHub Desktop.
Save rutger1140/9993776 to your computer and use it in GitHub Desktop.
Check for JS and SVG support and add/remove HTML classes accordingly. Snippet used in <head>
<script>
// Check for javascript support
(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement);
// Check for SVG support
(function(H){if(!!("createElementNS"in document&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect)){H.className+=" svg"}else{H.className+=" no-svg"}})(document.documentElement);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment