-
-
Notifications
You must be signed in to change notification settings - Fork 315
Dynamic CSS Loading #9
Comments
many people have asked for this before. i have no plans to add it to LABjs at the moment, and here's why:
Because that code is so trivially easy for people to do themselves if they want to load CSS dynamically, I don't think it belongs in a tool which is designed for the specific purpose of performance-efficient script loading. All this having been said, some other loaders do support CSS loading... like Dominoes and RequireJS. |
is there a way to know when the css has been loaded. so that i can make the div visible only when the callback has been fired. |
The most straightforward way is to have a CSS style in the stylesheet and then to poll every 25 ms and look for the computed style of some element to see if that style has been applied. Obviously that's kind of ugly, but I've done that successfully before. If you look in the source code for Dominoes there's a more complex solution that tries to actually detect if the stylesheet itself is loaded as a node in the DOM, and uses some interesting security behavior in various browsers. Either way, it's not straightforward or easy. That's one of the reasons I've not put it into LABjs. The complexity is not worth the payoff. |
closing (for now) |
beging able to load css dynamically would also be a great addition to LABjs. might be could be add as an extension to LABjs incase some of them don't want this feature.
The text was updated successfully, but these errors were encountered: