Close LightBox From Page Code (Preloader)

I want to use a lightbox as a preloader so i can call it from anyscreen via public js file.
I know the “wixWindow.lightbox.close();” code has to be run from inside the lightbox but is there any way i can call a method in the lightbox that will then run this code?

Note that Wix uses javascript and not html.

You can look at different preloaders that are already out there.

From Wix.
https://www.wix.com/corvid/example/promotional-preloader

Wix already do a welcome screen preloader for mobile versions here.
https://support.wix.com/en/article/adding-a-welcome-screen-to-your-mobile-site

From Wix Corvid Forum.
https://www.wix.com/corvid/forum/community-discussion/real-preloader-on-a-wix-website

From Vorbly.
https://www.vorbly.com/Vorbly-Code/WIX-CODE-HTML-PRELOADER

From Wix Training Academy.
How To Create A Custom Preloader Screen in Wix

From Picklewix.
https://www.picklewix.com/wix-preloader

From FutureCode.
https://futurevisionweb.wixsite.com/futurecodemain/preloader-tool

Wix Create
https://www.wixcreate.com/create-a-pre-loader

firstly, thanks for the correction. I meant public JS file but typed in html instead.

I’ve read through the majority of these and most if not all seem to not solve my problem.

I am trying to accomplish the following:

  1. use custom preloader (gif)
    2.) use show/hide preloader functionality was a utility rather than having to add the full code to every page

I was trying to accomplish this with a lightbox as it is an element I can call from anywhere without having to add it to my page and potentially hinder my ability to easily edit the page itself.

However, like I stated closing the damn thing seems to be an issue since it must be closed from inside the lightbox.

@woodsaaronz I would advise against this because lightboxes are inherently slower to load than just an element pinned to screen and set to show on all pages. It’s going to be a preloader that slows down the actual load itself which is never a good idea.

But if you want, you can just put setTimeout(() => wixWindow.lightbox.close(), 300) in your lightbox code.