███████████  █████         █████████     █████████  █████   ████    █████       ██████████   █████████   ██████████  
▒▒███▒▒▒▒▒███▒▒███         ███▒▒▒▒▒███   ███▒▒▒▒▒███▒▒███   ███▒    ▒▒███       ▒▒███▒▒▒▒▒█  ███▒▒▒▒▒███ ▒▒███▒▒▒▒███ 
 ▒███    ▒███ ▒███        ▒███    ▒███  ███     ▒▒▒  ▒███  ███       ▒███        ▒███  █ ▒  ▒███    ▒███  ▒███   ▒▒███
 ▒██████████  ▒███        ▒███████████ ▒███          ▒███████        ▒███        ▒██████    ▒███████████  ▒███    ▒███
 ▒███▒▒▒▒▒███ ▒███        ▒███▒▒▒▒▒███ ▒███          ▒███▒▒███       ▒███        ▒███▒▒█    ▒███▒▒▒▒▒███  ▒███    ▒███
 ▒███    ▒███ ▒███      █ ▒███    ▒███ ▒▒███     ███ ▒███ ▒▒███      ▒███      █ ▒███ ▒   █ ▒███    ▒███  ▒███    ███ 
 ███████████  ███████████ █████   █████ ▒▒█████████  █████ ▒▒████    ███████████ ██████████ █████   █████ ██████████  
▒▒▒▒▒▒▒▒▒▒▒  ▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒   ▒▒▒▒▒   ▒▒▒▒▒▒▒▒▒  ▒▒▒▒▒   ▒▒▒▒    ▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒   ▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒

Code Tutorials

All of these code snippets are free to use with or without credit. I also recommend having at least a cursory knowledge of HTML, CSS, and/or JavaScript before using any of them so that you don't have to rely entirely on my bad explanations.

Loader

Basically, all you need is this line of code:

window.addEventListener("load", showPage);

The showPage function is what executes after the page is loaded, and the "load" part is what it uses to determine when the page is done loading. You can rename showPage to be whatever you want the function to be named.

To have the loader disappear, you need to add whatever you want the loader to be at the top of the body tag in the HTML file and then have the showPage function execute on it through an id, which can be done with this line of code:

function showPage() {
document.getElementById("loadin").classList.add("fadeout"), setTimeout(disappear, 1e3)
}

Adding the class fadeout isn't necessary, it basically just plays a fadeout animation before the loader disappears, which is 1 second long (1e3). If you remove it, you can skip this part and replace the showPage function with the disappear function in the first piece of code. If you change how long the animation takes, make sure to change the 1e3 (1 second is 1000/1e3, 2 seconds is 2000/2e3, etc.).

Whatever the loader is in the HTML file should have the loadin id, or whatever you want to name it. I recommend adding an additional div around the loader and adding the loadin id to that so you get everything and don't have to worry about styling interfering with anything.

The disappear function makes sure the loader stays gone once it fades out/disappears, which is done with this function:

function disappear() {
document.getElementById("loadin").style.display = "none"
}

All of these functions should be in the same JavaScript file, the order they're in doesn't matter, but I recommend putting them in the order they execute so it's easier to parse. Add the JavaScript to the HTML file through a script tag placed at the very bottom of the HTML file before the final body tag:

<script src="loader.js"></script>

You could also just add it to the header by putting all the functions in script tags:

<script>

window.addEventListener("load", showPage);

function showPage() {
document.getElementById("loadin").classList.add("fadeout"), setTimeout(disappear, 1e3)
}

function disappear() {
document.getElementById("loadin").style.display = "none"
}

</script>

This only covers the JavaScript side of things, since what your loader looks like is completely up to you. As long as whatever you create is in a div with the loadin id you should be good. I also give you my blessing to inspect element my website if you want to see exactly how I did it.