Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent images from loading

Tags:

javascript

is there a way with javascript/jquery to prevent images from loading? I am building a slideshow from a html list with images. So I would like to collect all the src data and then prevent the images from loading. So later when the user really needs the image I would load it then.

I found some lazy loading script on google but couldn't find the way they prevent images from loading.

Thanks in advance.

Edit1:
It seems from the answers that it's not possible to use javascript to prevent images from loading. Here is a script that does lazy loading. Could anybody explain how it works? It seems when javascript is off it just loads the images normaly and when it's on it will load them when you scroll to their location.

like image 299
Pickels Avatar asked Nov 03 '09 15:11

Pickels


People also ask

How do I stop pictures from loading in Chrome?

How to disable image files from displaying in Chrome? Open Google Chrome and click the Customize / Control Google Chrome button > Settings. Scroll down and click on "Show Advanced settings ". In the Privacy section, click on Content settings....

How do I stop the loading of images in browser settings?

Here's how. 1. Launch Firefox, type in about:config in the address bar, and hit Enter. That is where you can turn on or off the auto image loading option.

Does display none prevent images from loading?

If you make the image a background-image of a div in CSS, when that div is set to "display: none", the image will not load. When CSS is disabled, it still will not load, because, well, CSS is disabled.


1 Answers

You can wrap the image in a noscript tag:

<noscript> <img src="foo.jpg"/> </noscript> 

All browsers that has JavaScript enabled will ignore the image tag so the image won't load.

like image 145
Sheldon Avatar answered Sep 24 '22 06:09

Sheldon