Say i wanted load internally downloaded css and js files as an alternative to the following links if CDN was not working, how would i do it?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css">
One way I can think of is to use the
onerrorhandler of the script tag, which will be called if the resource was not well loaded and after this you can load dynamically/manually the script from somewhere else.Another way, is to just check after the CDN script if you have the resource you expect, and if not you can create a new script with different URL, something like this: