开发者

jQuery Preloader Animation

开发者 https://www.devze.com 2023-03-20 17:23 出处:网络
I want to \"preload\" the start page of my website with a littl开发者_运维问答e gif-animation. Its a 3-frame-piece and I want to show it right before the first page. Are there plugins to preload a pag

I want to "preload" the start page of my website with a littl开发者_运维问答e 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?


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号