Skip to content

Instantly share code, notes, and snippets.

@steveluscher
Created July 5, 2015 19:22
Show Gist options
  • Save steveluscher/817471b8ab0af42f5d67 to your computer and use it in GitHub Desktop.
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
<!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