Lightbox delay.

Hi! First of all, I’m kind of a noob in Corvid, so sorry in advance for dumb errors my code may have.
I have turned my lightbox into a one-time popup following this tutorial . Here’s what i wrote:

import {session} from 'wix-storage';
import wixWindow from 'wix-window';

$w.onReady(function () {
 if(!session.getItem("firstTimePopupShown")) {
    wixWindow.openLightbox("Welcome");
    session.setItem("firstTimePopupShown", "yes");
  }
} );

It works exactly as intended, but the problem now is that whenever a “first visitor” acceses the page, there’s a delay on the lightbox (about one second approx.) and visitors see my content before seeing the lightbox, which kind of ruins it.
I’ve noticed that it may has to do with the loading of the page, so I made a preload screen and see if it solved the problem. It didn’t.

So right now I have ran out of ideas and I don’t know what to do. Can anybody provide me the solution?