javascript – In the new browsers will there be no more synchronous requests now?

Question:

I saw today on my Google Chrome , updated to version 40.0.2214.91 , a message that said

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience

translating:

Synchronous XMLHttpRequest in the main thread is discouraged because of its detrimental effects on the end-user experience

This means that, for new browsers, requests via AJAX will no longer have the synchronous request.

Should I start changing the way of programming now, thinking about this directive being removed in the future?

Answer:

Yeah, that's the idea. See the specification :

Synchronous XMLHttpRequest outside of workers is in the process of being removed from the web platform as it has detrimental effects to the end user's experience. (This is a long process that takes many years.) Developers must not pass false for the async argument when the JavaScript global environment is a document environment. User agents are strongly encouraged to warn about such usage in developer tools and may experiment with throwing an InvalidAccessError exception when it occurs.

What the browser is doing is following the above recommendation to advise that this is a feature that should not be used. Either use the asynchronous request or do it in a thread ( worker ).

Note that this will take so long that little done today will be alive until then. Terrible things, far worse than this, that were allowed 20 years ago still work in browsers today.

Unfortunately there are no more alerts. The vast majority of developers use things they shouldn't do a lot and don't even know about it. Not only in JS in browsers, this goes for many languages ​​and diverse functionality.

If something is considered obsolete, it should no longer be used for new things and whenever you have the opportunity to change something that already exists, it should be done.

Of course, if you don't do it, you won't have problems for a long time, but that's the attitude of each professional and the resources (mainly time to modify the existing one, although it's quick in this case) that each one has.

But if you think about it, making the synchronous request doesn't make much sense. If this is to be done, call the page. Many people think that AJAX is a programming language. It's just a very specific technique using XMLHTTPRequest and the A stands for asynchronous (Asynchronous Javascript And XML). But nobody uses XML anymore 🙂

Scroll to Top