First of all try to find out how long it takes to the $w to be ready.
const start = Date.now();
console.log('START', start);
$w.onReady(()=>{
console.log('$w - start (ms)', Date.now() - start);
///...
})
Try to feel how long it takes to the initial start log to appear.
And look for the second log to see the gap between the $w and the start.
Maybe it’ll help understanding the situation.
Also check if you have any code in the masterPage.js file that might slow it down.