Re: [xhr] Abandon hope of removing sync XHR from the web platform? (#20)

Feeling relieved to know that sync XHR is going to stay! 

@marcoscaceres Sync XHR is important in advertising platform, perhaps it falls in <2% cases. Here goes an practical example. Please note, I tried to make the example "readable" as it might be too specific to the domain knowledge.

--- begin example --
Current problem: Supporting 3rd party tag based demand in MoPub SDK w/o Sync XHR.

Here is how mopub javascripts/html page looks like if XYZ ad network wants to add their tag:

```
<script>
// XYZ script here. It adds a script tag dynamically
// in the document with the ad request url expecting a JSOONP response 
// OR makes an Async XHR request.
XYZ.loadAd();

// mopub assumes, that if loadAd fails to deliver an ad,
// it should call MoPub.fail() here. so the next script won't be loaded
// or will have no effect.

// BUT, the script tag, even w/o async mode, 
// will be executed after the next script tag is evaluated. 
// I.e. following script tag will be executed either before or in parallel. 
// there is NO way to stop the JS engine to render the next script tag 
// w/o sync XHR, as far as I know.
</script>


// The following script tag is added by MoPub SDK before loading the full html page
// it to the browser.
// So we don't know what is in there beforehand. We can only inspected what they added.
<script>
// It is last block, so MoPub assumes that if reached here then
// an ad is delivered.
MoPub.AdReceivedSuccess().

// if  XYZ.loadAd() fails to deliver an ad and but if
// the above call is made before that, then MoPub 
// will count a false impression. That is really bad for business.
</script>
```
--- end example ---

Hope that gives you at least one use case of Sync XHR. However, If MoPub had a better/another way e.g callback/delegate etc, Sync XHR wouldn't be needed. 

But till then, in such many cases where we cannot change a big player - such 3rd party integration needs Sync XHR.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/xhr/issues/20#issuecomment-187188271

Received on Monday, 22 February 2016 14:06:53 UTC