1DMF
1DMF

Reputation: 2145

Synchronous XMLHttpRequest on the main thread is deprecated

Why has this message suddenly started to appear in the Firefox console?

I'm using JQuery 1.7.1.

What in my app could I be doing that has caused this message to start appearing?

Upvotes: 37

Views: 54223

Answers (2)

Jason Kester
Jason Kester

Reputation: 6031

Using jQuery to append a script tag to the document will cause it to load the script with async:false and trigger this warning.

As in:

var script = $("<script></script>");
script.attr("src", player.basepath + "whatever.js");
$(document.body).append(script);

Upvotes: 38

nmaier
nmaier

Reputation: 33162

You have code performing synchronous XHR/Ajax, i.e. Ajax requests that block until they are completed.

When using jQuery, you'd do so by specifying async: false in the settings object of jQuery.ajax().

The solution is to refactor any of your code doing synchronous requests, i.e. kill all instances of jQuery.ajax({async: false}) and helper functions, as well as xhr.open(..., false), include code in third-party libraries you may use. Also, since jQuery 1.7.1 is rather old by standards of the web, I'm not sure if that jQuery version still does internal sync requests in certain cases, you'll have to check for that as well and upgrade jQuery if so.

Upvotes: 15

Related Questions