How can I fix the slow website speed caused by deprecated APIs?

How can I fix the slow website speed caused by deprecated APIs?

Tomeliss
Tourist
14 0 2

So recently i ran in to a problem where by some reason my website is working so slow doe to this error. Can anybody help me fix this, it is ruining the site speed so bad. my error on google site speed test: 

Deprecated APIs will eventually be removed from the browser. Learn more about deprecated APIs.
 

Deprecation / WarningSource

masterysneakers.com
 1st Party
 
Synchronous `XMLHttpRequest` on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
Replies 4 (4)

rajvee_kadchha
Shopify Partner
25 1 2

Hello Tomeliss,

 

This warning from browser telling you that using synchronous XMLHttpRequest on the main thread is deprecated because it can have negative effects on the user experience.

 

Synchronous XMLHttpRequest halts the execution of the JavaScript code until the request is complete. This could lead to a frozen user interface and a poor user experience, especially if the requested resource is slow to respond or unavailable. That's why it's recommended to use asynchronous XMLHttpRequest instead.

 

Here's how you can make an asynchronous XMLHttpRequest:


var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.example.com/data", true); // true makes it asynchronous

 

If you find my suggestion difficult to implement send an email at rajvee.kadchha@mlveda.com 

Tomeliss
Tourist
14 0 2

Could you instruct me where should i implement this piece of code?

rajvee_kadchha
Shopify Partner
25 1 2

In your code, you will be able to find this section. Please refer to the screenshot, you just have to add the highlighted code.

rajvee_kadchha_0-1699275599407.png

 

Tomeliss
Tourist
14 0 2

May i know in which file is it?