Australia Bush Fires and the End of the World?

Hey!! remember the time when everything was normal and we even made jokes about WW3? Yeah, that is not the case anymore. A whole frickin country is on fire and you are sitting there in your lawn…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Make those animations wait!

There is nothing worse than landing on a nicely designed and developed website with some nice, subtle (ALWAYS subtle!) animations, only for the animations to start as soon as the page tries to load. What do you get? Janky, stuttery and definitely NOT subtle animations.

I’m going to assume you’re not allowing a site go live that takes longer than a second or two to fully load in the first place, but if you are (naughty!) then please do us a favour and consider a loading icon to avoid a blank page.

So, for our first step we need to use some javascript to detect the load event on the window. Make sure this is one of the first pieces of code to run on your site:

Now that we will know when the page is ready, we can add a class to the <body> tag which we will remove once the page is loaded, this will tell those (patiently waiting) animations to begin “surprising and delighting” us.

So you can see here in the first line we’re adding the ‘js-still-loading’ class to the <body> first thing and then once the page is fully loaded we’re removing it.

If we add this to our CSS:

All of our animations will remain paused for as long as that ‘js-still-loading’ class is present. That’s it. No need to add it to every single animation in your CSS, no need for any fancy javascript…and the benefits are no more janky, stuttery animations while the page is trying to load.

Add a comment

Related posts:

How Substratum is Building an Affordable Blockchain Network

Blockchain technology and the decentralized internet of the future promise web security, accessibility, and authentication for all. Why, then, do we still work with centralized server banks and…

Noah

Oh my goodness! I cannot believe I keep forgetting to post! There are so many thing happening in my life. Lots of ongoing adventures, but not the type that are conveniently photographed and shared…