1

So I'm looking for the best way to display a loading animation while the rest of my page loads.

I've been looking for a method that allows the animation to load quickly, stops once the website is loaded and the animation is set to display: none, is high quality with good framerate, and works on IE8 and above.

The options that I'm aware of are a gif animation, SVG, plain CSS or javascript. I'm thinking of the animation being as simple as this one, but am not limited to just that. https://d13yacurqjgara.cloudfront.net/users/21046/screenshots/1127381/sample.gif

Which method would best fit my needs?

1 Answers1

0

works on IE8 and above.

Use a .GIF, CSS animation using transforms will not be supported, JavaScript you will have to account for browser differences and SVG I'm not fully sure on.

I've been looking for a method that allows the animation to load quickly,

Any CSS to do with displaying the animation should be placed in the pages mark up (internal), this will ensure that it renders instantaneously on page load.

<style> 
  #loader{
   display: block;
   width: 10%;
   height: 10%;
   position: absolute;
   top: 45%;
   left: 45%;
   background-image: url(loader.gif);
   background-size: cover;
 }
</style>

while the rest of my page loads

Use JavaScripts .onload function to determine when the content has been fully loaded.

window.onload = function () { document.getElementById("loader").style.display = "none"; }
rssfrncs
  • 991
  • 4
  • 19