I am working on a website built with static HTML pages. My goal is to implement a full-screen loading status complete with a progress bar that indicates the page's load progress, including all images and external assets. Once the page has fully loaded, the loading screen will disappear, revealing the content to the user.
Although I have successfully detected when the page has completed loading by using the 'load' event listener on the window object, I am facing challenges in getting the progress bar to display as expected. I aim to show the progress in percentage format, which requires me to calculate the overall size of the page including all assets and monitor the resources being transferred so I can convert it into a percentage value.
After conducting some research, I have found that there isn't a simple solution for this task. However, I have noticed many websites implementing similar progress bar loading animations.
My question now is: How can I achieve a similar effect on my website? I want to provide users with a visual representation of the loading progress in percentage as they wait for the page to load.