Featured post
javascript - Is there any way to detect when a CSS file has been fully loaded? -
i've been testing lot of lazy-loaders javascript , css
insert <script> , <link> tags load files. problem is, <link>
tags don't fire onload
it's difficult detect when they're loaded. workaround found set display: none;
(in css
file loaded) on dummy element , poll element check when has been set display: none. that, apart being ugly, of course works single css
file.
so wondering; there other way detect if css
file has been loaded?
thanks, lukas
--
ps: found solution, it's @ bottom of page. (i'm new stackoverflow , i'm sure answer supposed @ bottom, think overseen if googleusers stuble upon page, wrote little note)
edit: should noted browser support onload events on css files has improved since original answer. not supported though, answer below still has relevance. here compatibility chart, not sure how legit source though.
ok, found solution.
this guy http://tugll.tugraz.at/96784/weblog/9080.html inserts link-tags , polls document.stylesheets[index].rules until no longer undefined (where index of course index of newly inserted file). unfortunately code buggy , works safari & ff. fixed bugs, added functionality opera , internet explorer , added features adding multiple css , js files , 1 final callback (when files loaded) in sweet , simple lazyloader-function. result can found here:
- Get link
- X
- Other Apps
Comments
Post a Comment