mobify/mobifyjs — pull request #166 by noahadams (2013-06-05 22:17:00+00:00)
Title: onerror handler for resizer

!! NOT TO BE MERGED JUST YET !!
This is still short tests, but I'm looking for some feedback.

The goal here is to make pages survive an outage of the image resizing service somewhat intact, though less performant.

So, there are three ways to attach an error handler to an image element
1. using `el.addEventListener` in js
2. setting the `el.onerror` property
3. adding the `onerror="..."` HTML attribute

I had an original implementation using 1., but realized there was going to be a race attaching the handler in the generated document, and that 3., however ugly, was a very simple workaround for this. The only substantive problem I can think of with it is overriding an existing onerror handler, though we could easily check for that and not do it.

Anybody have any serious opinions about this?

Also, if you want to give the demo a try I recommend using charles or /etc/hosts to point ir0.mobify.com to nowhere inparticular.