37

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?

nmaier
  • 32,336
  • 5
  • 63
  • 78
1DMF
  • 2,045
  • 4
  • 15
  • 17

2 Answers2

39

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);
Jason Kester
  • 5,951
  • 9
  • 35
  • 40
  • 2
    I stumbled across this warning recently when using the knockout.js html binding. If jQuery is available, knockout uses it under the covers to manage dom manipulation for the html binding. If there are any script tags in the html string being rendered, it will trigger this warning. – kiprainey May 27 '15 at 14:26
  • 1
    Is this deprecation warning saying that in future versions of jQuery, the `async: false` attribute will be ignored and requests will be issued asynchronously anyway? – RTF Jun 19 '15 at 10:00
  • Is there a way to resolve this warning? Or can it be ignored? – Sticky Feb 24 '16 at 02:08
  • Is this deprecation eventually going to force my hand since I have no control over users updating their browser (compared to the way that I can control the version of a library I use) or will this be a sort of perpetual warning? – RTF Mar 15 '16 at 12:36
15

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.

吳強福
  • 373
  • 1
  • 2
  • 18
nmaier
  • 32,336
  • 5
  • 63
  • 78