简体   繁体   English

避免使用javascript加载图片

[英]avoid loading images using javascript

Say I have the following code in my html: 说我的html中有以下代码:

<html>
  <....> 
   <img src="the-image.gif" />
  <....>
</html>

Is it possible to avoid loading the image using javascript? 是否可以避免使用javascript加载图像? I want to load it later, using javascript. 我想稍后使用javascript加载它。 But I don't want it to be loaded automatically. 但我不希望它自动加载。

I am trying to delay the request of the image. 我试图延迟图像的请求。

Thanks 谢谢

You can use the LazyLoad jQuery Plugin . 您可以使用LazyLoad jQuery插件

Lazy loader is a jQuery plugin written in JavaScript. Lazy loader是一个用JavaScript编写的jQuery插件。 It delays loading of images in (long) web pages. 它延迟了(长)网页中图像的加载。 Images outside of viewport (visible part of web page) wont be loaded before user scrolls to them. 视口外的图像(网页的可见部分)在用户滚动到它们之前不会被加载。 This is opposite of image preloading. 这与图像预加载相反。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM