So I am testing a script at the moment and publish it with surge. Locally it works 100% of the time but whenever after publishing I get this error/warning message:
jquery-2.1.4.min.js [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience."
I researched and found out that it has to do with async set to false. The script where its getting triggered below:
$(function(){
$.getJSON('https://api.etherscan.io//api?module=stats&action=tokensupply&contractaddress=&apikey=4IEDV8D2CVTXVE2VFMUBSTUYVY827Q9GG1', function(data) {
// Parse JSON file
var myJSON = data;
//Put result in var
var string = myJSON.result;
//Parse long string to right format
const str = string;
const res = str.slice(0, 3) + str.slice(3, 6);
//Apply result to html element
var elementSupply = document.getElementById("supply");
if (elementSupply) {
// elementSupply.innerHTML = res;
$("#supply").html(res);
}
if (document.getElementById("supply") === null) {
// elementSupply.innerHTML = res;
$("#supply").html(res);
}
});
});
Nowhere is the 'async false' called. And I know that it is in this script because whenever I remove it, the warning message disappears.
Anyone has a clue? Thanks in advance.