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

196
Views
Chrome doesn't fire "onerror" event for "link" tag?

I am updating the theming system for a website, and I am trying to handle when a <link rel="stylesheet"> element fails to load a theme so that I can have it fallback to a default theme (as well as to identify outdated theme selections, etc.).

In Firefox, I can use the "onerror" event through jQuery before setting the href attribute, e.g. $("#myLinkElement").one("error", handleThemeLoadError).attr("href", themeUrl).

If themeUrl refers to a CSS file that does not exist (resulting in a 404), the handleThemeLoadError is called.

In Chrome, however, the onerror event is never fired. I see the 404 error in the console and network tabs, and Chrome even shows me the line of code where the attribute is set that caused the 404 error, but it will not fire an error event. I have even tried $("#myLinkElement").get(0).onerror = function() { ... }, and I've also tried setting the href attribute to both null and undefined before setting it to the actual URL.

Is there some other way to catch stylesheet load errors in Chrome, or am I completely out of luck?

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!