(Sync XHR should be avoided because it is bad for the UX.)
(In reply to Olli Pettay [:smaug] from comment #1) > (Sync XHR should be avoided because it is bad for the UX.) I agree that sync calls should be avoided. But we are using dojo 1.6 heavily in our project which uses sync xhr calls to download the scripts when dojo.require is called. We can't upgrade to higher versions of dojo (which uses AMD) yet because it will require some time to resolve all the regressions. Thus we can't avoid these sync calls. I have presented here minimal code so it could be easily debugged.
There's nothing to debug, really: sync XHR spins the event loop, so events (including async script execution and whatnot) can fire under a sync XHR call....
(In reply to Boris Zbarsky (:bz) from comment #3) > There's nothing to debug, really: sync XHR spins the event loop, so events > (including async script execution and whatnot) can fire under a sync XHR > call.... Please pardon my ignorance. I didn't understand when you said "spins the event loop". I was expecting that when a synchronous xhr request is sent, execution blocks until the request is done. But in firefox instead it starts evaluating the next script in the order which seems to be incorrect as current script execution is not yet finished. The above works perfectly fine in google chrome as expected.