Hide preloader when page finished loading

I have this code in my app.js

app.dialog.preloader(‘Loading’, ‘orange’);
app.on(‘pageInit’, function (page) {
app.dialog.close();
});

but the preloader hides too soon for the page to have completely finished loading.
I use Template7 to pull the index content.

Can someone point me in the right direction? I’m still learning :slight_smile:
Thanks in advance!

If you want the preloader to last a while, you can do one of 2 things:

  1. Tie it to a javascript action/callback so that the close action will only be executed after the initial action is complete

  2. Use a timer. Set the preloader to close after a number of seconds