Today I learned: if you start a load navigation in a subframe from script before your page is done loading, Chrome and Safari will fire your page's onload before that subframe load completes.
-
Show this thread
-
Replying to @really_bz @bz_moz
do you mean a script that injects content into the iframe or just adding an iframe with a src?
1 reply 0 retweets 0 likes -
Replying to @bluesmoon
I mean adding an iframe with an src. If you set the src first then add, load event waits for that load. If you add, then set src it does not.
1 reply 0 retweets 0 likes -
Replying to @really_bz @bz_moz
this happens because without an src, the iframe’s onload event fires immediately. We use this hack here:http://www.lognormal.com/blog/2012/12/12/the-script-loader-pattern/ …
1 reply 0 retweets 0 likes -
Replying to @bluesmoon
I'm talking about the load event of the iframe's parent, not the iframe itself.
2 replies 0 retweets 0 likes -
Replying to @really_bz @bz_moz
yeah, the blog post explains it (I hope). The parent does in fact wait for the iframe’s onload, which fires immediately (before the src is added), after that the parent will not wait for further onload events.
1 reply 0 retweets 0 likes -
Replying to @bluesmoon
The parent is supposed to wait for fetches, not for onload events, per spec. Edge and Firefox get this right.
1 reply 0 retweets 0 likes -
Replying to @really_bz @bz_moz
That’s news to me, this method for loading subresources outside the critical path has worked for us in production for the last 6 years across thousands of sites.
1 reply 0 retweets 0 likes
Your method is loading things inside the iframe, not navigating the iframe.
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.