<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<script src="myscript.js"></script>
</head>
I’d like to have a function that checks if a resource is included in the head
checkIfHeaderHas('myscript.js'); // would return true
checkIfHeaderHas('mystyle.css'); // would return true
checkIfHeaderHas('mybla.css'); // would return false
But I’m wondering how I can go about searching the head for a filename? (in the ‘src’ if it’s javascript, or in the ‘href’ if it’s a css)
Using the .length in jquery would work for this. (Not tested!)
Just check to see if a element exists with the href attribute set to your CSS file’s URL: