I was hoping to use $.ajax({url:'foo.js', async:false, dataType:'script'})
to block content display until foo.js had loaded. The assumption was that synchronous script loading is roughly equivalent to document.write
. I'm guessing that's incorrect since I still get FOUC.
While I can solve the immediate issue by hiding the element and showing it on script load, I'm curious how the synchronous $.ajax
call differs from document.w开发者_StackOverflow社区rite
. If you happen to know a way to get content blocking behavior from jQuery, that would be interesting also.
Thanks!
Adam
You could define a variable/construct in foo.js, and wait for its definition.
The .load() function can be used to wait on a certain element's load: http://api.jquery.com/load/
精彩评论