Languages
[Edit]
EN

JavaScript - script loading error event

0 points
Created by:
a_horse
538

In this article, we would like to show you the script loading error event in JavaScript.

Quick solution:

 

Practical example

Edit

In this example, we create index.html with incorrect src property and add the onerror event to display a message on script loading error.

Result:

JavaScript - script loading error event
JavaScript - script loading error event

Alternative solution

Edit

In this example, we add a function to the script element onerror property to handle the script loading error.

References

Edit
  1. GlobalEventHandlers.onerror - Web APIs | MDN

Alternative titles

  1. JavaScript - script loading onerror event
  2. JavaScript - on script loading error
  3. JavaScript - .js file loading error
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join