Created
July 5, 2015 19:22
-
-
Save steveluscher/817471b8ab0af42f5d67 to your computer and use it in GitHub Desktop.
Simple way to apply a class to an HTML document if Javascript is disabled
This file contains 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
<!DOCTYPE html> | |
<html class="no-js"> | |
<head> | |
<script type="text/javascript"> | |
// If JavaScript is enabled, this code will synchronously modify the <html> | |
// element's class attribute, before anything else has a chance to run. | |
document.documentElement.className = document.documentElement.className.replace( | |
/(^|\s)no-js(\s|$)/, | |
'$1js$2' | |
); | |
</script> | |
</head> | |
… |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment