Synchronous XMLHttpRequest warning and [removed]

前端 未结 7 1949
猫巷女王i
猫巷女王i 2020-11-27 16:56

I\'m getting a warning message:

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

7条回答
  •  天涯浪人
    2020-11-27 17:20

    Browsers now warn for the use of synchronous XHR. MDN says this was implemented recently:

    Starting with Gecko 30.0 (Firefox 30.0 / Thunderbird 30.0 / SeaMonkey 2.27)

    https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests#Synchronous_request

    Here's how the change got implemented in Firefox and Chromium:

    • https://bugzilla.mozilla.org/show_bug.cgi?id=969671
    • http://src.chromium.org/viewvc/blink?view=revision&revision=184788

    As for Chrome people report this started happening somewhere around version 39. I'm not sure how to link a revision/changeset to a particular version of Chrome.

    Yes, it happens when jQuery appends markup to the page including script tags that load external js files. You can reproduce it with something like this:

    $('body').append('');
    

    I guess jQuery will fix this in some future version. Until then we can either ignore it or use A. Wolff's suggestion above.

提交回复
热议问题