I need to make a HTTP Call before the site loads

I have some placeholder text in a textbox (“Day day_placeholder”)

When onReady() runs, I make an HTTP call through the Wix backend and I make some HTML replaces to change what is shown. That part is working.

The problem is that the HTTP Call is taking too long and is only making the request after the site is load. I tried to use hide() and show(), but it takes even longer to the site to load.

Perhaps this one?

$w.onLoad(()=>{
	setTimeout(()=>{
		//rest of code???
	},5000)
})

Call the http in the page outside the onReady() function using promise.
Consume the promise outside or in the onReady() function.

You may consider using a router (it depends on what exactly you’d like to achieve).
On router trigger run the http-call and when you get the response, load the page (pass the response if needed).

https://support.wix.com/en/article/velo-creating-a-router

Alternatively start from collapsed elements.
Run the http call from the global scope and show the elements once it’s ready.
Something like:

import {callFunction} from "backend/my-function.jsw";
let is$wReady, response;
callFunction().then(r => {
response = r;
if(is$wReady){displayElements();}
})
$w.onReady(() => {
is$wReady = true;
if(reponse){displayElements();}
});
function displayElements(){
//expand the elems
})