Julius Koroll
Julius Koroll

Reputation: 225

jQuery Preloader Animation

I want to "preload" the start page of my website with a little gif-animation. Its a 3-frame-piece and I want to show it right before the first page. Are there plugins to preload a page with a specific animation shown?

Upvotes: 1

Views: 528

Answers (1)

user166560
user166560

Reputation:

You don't need a plugin, or even jQuery. Just assign the image to a variable in the <script> block in the <head> of your page. JavaScript prevents the content from loading until it has done it's job, so the image will already be cached by the page visitor when the HTML is rendered:

<head>
  <script>
    var animation = new Image();
    animation.src = "images/animation.gif";
  </script>
</head>

<body>
  <div>
    <img src="images/animation.gif" alt="oooh! lookee!"/>
  </div>
</body>

Upvotes: 1

Related Questions