Load code after site is loaded

I´m struggeling with a problem and the workaround seems to be to load the code after the site is completely loaded. Does anybody can give me an example?

Have found a workaround:

setTimeout (()=>{ YOUR CODE } );}, 2500 ) //2500milliseconds = 2,5sec.

Maybe someone have anyway a code which makes loading the code, after the site is loaded completely…

$w.onReady(()=>{
   console.log('page is ready.., continue with your code below...');
   
   //your code here....
   //your code here....
   //your code here....
   //your code here....
   //your code here....
   //your code here....
   //your code here....   
});

Good joke. It doesn´t work. This is a working code which will be applied after 2,5ms. The orange colored is your code. In my case it opens up a modal window.

import wixWindow from ‘wix-window’;
setTimeout(()=> {wixWindow.openModal(“https://www.aboutyou.de/frauen/accessoires”, {
“width”: 1024,
“height”: 500
} )
.then( () => {
console.log(“Modal closed.”);
} );},2500) //2500milliseconds = 2,5sec.

Depends on the internet connection of the user site loading could take longer than 2,5ms. Does anybody has an idea how to applie a code after a site is fully loaded? Big thank you!