Last active
March 11, 2023 21:38
-
-
Save cvan/8a188df72a95a35888b70e5fda80450d to your computer and use it in GitHub Desktop.
check if a CSS stylesheet has 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
var linkEl = document.head.querySelector('link[href*="/styles/index.css"]'); | |
var cssLoaded = Boolean(linkEl.sheet); | |
linkEl.addEventListener('load', function () { | |
cssLoaded = true; | |
}); |
@VAggrippino check the updated gist now. that should work.
@VAggrippino What browser were you testing in?
if(document.head.querySelector('link[href*="/index.css"]') != null)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is enough:
It work both for correct and incorrect CSS files.