on-internet
← Community

Detect style sheet load

Stack Overflow ·

What are good ways to detect whether a style sheet has loaded using vanilla JavaScript? I understand they do not have the same load event that images and scripts fire. Loading as packed into a .js file (like with WebPack 'loaders') is not an option. 2022 update: All major browsers have now supported onload= on <link rel=stylesheet> tags for years, so that would be the obvious way to detect when CSS has loaded. Note also that external stylesheets in the head are blocking during page load, but can be added later with JS to make them asynchronous. It’s that scenario in which my question is releva

Comments

Sign in or sign up to comment and upvote.

No comments yet.