Last active
August 29, 2015 14:03
-
-
Save ItangSanjana/edadf9f0749413eae6b0 to your computer and use it in GitHub Desktop.
HTML + JavaScript : Add class to documentElement immediately then remove it 1 sec after window loaded.
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
<html> | |
<head> | |
<script>document.documentElement.className += "loading";</script> | |
</head> | |
<body> | |
<script> | |
(function () { | |
'use strict'; | |
function removeTheClass() { | |
var rootElement = document.documentElement; | |
if (rootElement.classList.contains('loading')) { | |
setTimeout(function () { | |
rootElement.classList.remove('loading'); | |
}, 1000); | |
} | |
} | |
window.onload = removeTheClass(); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment