MooTools 1.2 Asset.css onload problem, and fix
Published July 3rd, 2008As part of the experiments I mentioned yesterday, I’ve been looking at the feasibility of loading CSS on-the-fly. MooTools has a method to achieve this (Asset.css) but I found to my disappointment that its onload event only works in Internet Explorer, so in other browsers you have no way of knowing when the CSS has finished loading (or if it’s failed).
I posted a bug report yesterday and as far as I can tell it’s slated to be looked at for the next release (1.3), but while pondering the problem overnight I came up with an idea and with some help from this blog post I was able to create an interim fix. Because it uses XMLHTTPRequest it can’t load CSS from a third-party domain, but it works for what I need and it’s better than nothing until the official fix is forthcoming.
I’ve put the code into this file (right-click, save as…) which you simply load after MooTools itself (it replaces the existing Asset.css definition with a new one).
Daniel on July 3, 2008
Hey, thanks for this hint! I’ve just posted on Mootool’s Google Groups…