I got into work today and got a telling off from my boss because the company website wasn't loading properly on mobile. I looked in the console and saw the following error... Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
. I clicked the link https://xhr.spec.whatwg.org/#xmlhttprequest and the update was made yesterday (7th June 2016). How do I fix this error?
Asked
Active
Viewed 601 times
0

Amesey
- 822
- 2
- 16
- 33
-
"the update was made yesterday " — The spec might have been updated yesterday, but that update didn't deprecate the feature. Synchronous requests have been deprecated for ages. – Quentin Jun 08 '16 at 09:51
1 Answers
0
Usually the message you provided should not break a page from being rendered. It just states that you should not use Synchronous XMLHttpRequest. Synchronous requests will slow down rendering since the site has to wait for each request to complete in an iterative manner. To "fix" that all your AJAX requests must be set to be async.

oberbics
- 408
- 4
- 12
-
when add the `async` attribute i get these errors... `(index):1769 Uncaught ReferenceError: google is not defined(anonymous function) @ (index):1769` – Amesey Jun 08 '16 at 10:05
-
Its nut sufficient to just make the requests async! You need to adhere to the "async programming paradigm" like providing callback handlers, etc. [This](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests) might help to understand or [that](http://stackoverflow.com/questions/748175/asynchronous-vs-synchronous-execution-what-does-it-really-mean?rq=1) – oberbics Jun 08 '16 at 10:08
-
Thanks, I read all that but I just don't understand how i'm suppose to load in `` or any other script now. – Amesey Jun 08 '16 at 10:22
-
Script loading will not trigger the "synchronous" warning. Thats something completely different. Usually the browser parses the HTML file and loads the script (and the other stuff as well). In e.g. your document ready function you can then use it then. But I think without example code it will be ahrd to get anywhere here ... – oberbics Jun 08 '16 at 10:46