Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

220
Views
How to programmatically get reason for why a script resource failed to load

I am creating and attaching a script tag dynamically in a script. Along with that I am adding an onerror handler. However, when the script fails to load I don't get any details as to why it failed. I would expect some details about script not available (a 404) , or timeout or anything else useful. Any way to get that information ? Note that I need to get the data programmatically so I can send it to Sentry. It’s for debugging user errors and I may not have access to their browsers and dev tools

const newScriptElement = document.createElement('script');
newScriptElement.src = url;
newScriptElement.type = 'text/javascript';
newScriptElement.async = true;
newScriptElement.id = scriptId;
newScriptElement.onerror = (ev) => {
   console.log(ev.message); // <-- The message property doesn't exist. But also no other message like property 
};
document.head.appendChild(newScriptElement);

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!