Add a handler for the onerror
and/or onload
events.
<script>
function errorHandler(script) {
script.src = "backupLib.js";
}
</script>
<script src="someLib.js" onerror="errorHandler(this)"></script>
Add a handler for the onerror
and/or onload
events.
<script>
function errorHandler(script) {
script.src = "backupLib.js";
}
</script>
<script src="someLib.js" onerror="errorHandler(this)"></script>
Browser developer tools will helps you...
Load the website in the browser and open the developer tools then network tab, refresh the page.
There you can see the status of resources, what are all loaded in the page(images,js,css..), If the status code was 200 then it is OK.
But we can use onload event handler instead like this :
<script>
function fileLoaded(name) {
console.log('JS File loaded # '+ name );
alert('JS File loaded # '+ name );
}
function fileLoadingError(name) {
console.log('File error # '+ name );
}
</script>
<script src=".../jsFile.js" onload="fileLoaded('1')" onerror="fileLoadingError('1')"></script>
Make sure to keep the function first.
Even if there's error, the onload method will be called.