I need to check the preticular css file is loaded or not in the current page using javascript.

Suggest any idea to find this using javascript.


1. CSS says: Hello I was (not) loaded

If you have control over how the CSS is loaded you can add events

This extract from my Fabric Iconator checks if the file was not loaded

<link rel="stylesheet" type="text/css" 

So you can add the onload (for a succesful load) event and track whatever you need to track

2. Hello CSS, are you a DOM element?

LINK and STYLE tags are DOM elements, so like any element you can check if they exist

var myCSS=document.querySelector("link[href*='6.0.1']")

will return undefined if it doesn't exist

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.