0

I have a third party JS script with class Oreole defined there. This script is located on a CDN server elsewhere. I have this reference in my HTML:

<script src="https://someothercdn.com/oreole.js"/>

Later in my page script code I have

let oreole = new Oreole

Sometimes the CDN fails with 504 or 502 and my code crashes. Usually, page reload helps. But how do I force script reload on my page?

if (typeof(Oreole) == "undefined") {
  //Do what exactly?
}
alt-ja
  • 144
  • 1
  • 11
  • Does this answer your question? [How to force a script reload and re-execute?](https://stackoverflow.com/questions/9642205/how-to-force-a-script-reload-and-re-execute) – marzelin Nov 12 '20 at 12:09
  • as a note, you should probably using webpack for such things –  Nov 12 '20 at 12:31

1 Answers1

0

You should probably host oreole.js somewhere else, but if you want to go with unreliable cdn, you can do something like this using jquery

$.getScript("https://someothercdn.com/oreole.js", function() {
 // do everything that needs oreole.js here
});

The page will keep running atleast, if oreole.js is not found or something happens only oreole part will crash

Aurangzeb
  • 1,537
  • 13
  • 9