Forum Moderators: open

Message Too Old, No Replies

jQuery-3.3.1.min.js and a message

         

toplisek

8:46 pm on Sep 8, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have all the message like: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience.
As I understand it is related to browser, not jQuery. Some remind were seen per internet: The API is guaranteeing that if you attempted to use the loaded HTML in the line of JavaScript after the .load() it would be available. If the request is changed to an async request, jQuery can no longer guarantee that the loaded HTML is available.

I'm using code inside Javascript:
myslider = {
init: function() {
var $ = jQuery;
$('.slide_show').mySlider(
{
mode: 'fade',
useCSS: false,
speed: 100
}
);
}
}

How to avoid this warning?
Is it enough to put all the time $.ajax in the start?
init: function() {
var $ = jQuery;
$.ajax('.slide_show').mySlider(
{
mode: 'fade',
useCSS: false,
speed: 100
}
);
}
}


[edited by: not2easy at 9:54 pm (utc) on Sep 8, 2018]
[edit reason] readability [/edit]

NickMNS

1:51 am on Sep 9, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If the request is changed to an async request, jQuery can no longer guarantee that the loaded HTML is available.

You can use promises to ensure that any code requiring the loaded html will only be called once and if the html is actually loaded. I'm not sure if the jQuery promise is sufficient for this, but the plain JS promise API will ensure this. As such the rest of your page can load and render without blocking the thread while you wait for that request to load.

toplisek

12:18 pm on Sep 14, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why Google Chrome keeps this outdated warnings when using Console?