Skip to content

Instantly share code, notes, and snippets.

@cvan
Last active March 11, 2023 21:38
Show Gist options
  • Save cvan/8a188df72a95a35888b70e5fda80450d to your computer and use it in GitHub Desktop.
Save cvan/8a188df72a95a35888b70e5fda80450d to your computer and use it in GitHub Desktop.
check if a CSS stylesheet has loaded
var linkEl = document.head.querySelector('link[href*="/styles/index.css"]');
var cssLoaded = Boolean(linkEl.sheet);
linkEl.addEventListener('load', function () {
cssLoaded = true;
});
@cvan
Copy link
Author

cvan commented Dec 3, 2019

@VAggrippino check the updated gist now. that should work.

@Finesse
Copy link

Finesse commented Dec 3, 2019

@VAggrippino What browser were you testing in?

@jgarcianewemage
Copy link

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