This is an example from Google Adsense application page. The loading screen displayed before the main page showed after.
I don\'t know how to do the same th
I had to deal with that problem recently and came up with a solution, which works just fine for me. However, I've tried @Ori Drori solution above and unfortunately it didn't work just right (had some delays + I don't like the usage of setTimeout
function there).
index.html
file
Inside head
tag - styles for the indicator:
Now the body
tag:
And then comes a very simple logic, inside app.js
file (in the render function):
const spinner = document.getElementById('spinner');
if (spinner && !spinner.hasAttribute('hidden')) {
spinner.setAttribute('hidden', 'true');
}
How does it work?
When the first component (in my app it's app.js
aswell in most cases) mounts correctly, the spinner
is being hidden with applying hidden
attribute to it.
What's more important to add -
!spinner.hasAttribute('hidden')
condition prevents to add hidden
attribute to the spinner with every component mount, so actually it will be added only one time, when whole app loads.