Upload Image Using Javascript

I make a site and one of the pages uses a javascript file from an external site

This external js contains (actually loads) an image that I do not need on my page.

How do I stop loading this image (let's say the img url is "http://image.com/img.png")? Is there any javascript code that can do this?

thank you everybody

+6
source share
5 answers

You can select an image with a URL and remove it from the DOM

$(document).ready(function(){ $('img[src="http://image.com/img.png"]').remove(); }); 

Update 1:

As you probably wanted a partial match, try the following:

 $(document).ready(function(){ $('img[src*="image.com/img.png"]';) }); 
+4
source

After loading the DOM, stop loading any of the resources ( window.stop() for modern browsers, document.execCommand("Stop", false) for IE). Then find the resources you need and ask them to download them.

+5
source

You cannot unload a single resource using JavaScript. As @nkamm replied, you can call the window.stop() method, but then it stops loading any resources (for example, clicking the Stop button in the browser).

If the image you are trying to stop the download from showing up in the DOM, is it worth it to cancel all other downloads on your page?

+2
source
 $(window).load(function(){ $('img[src="http://image.com/img.png"]').remove(); }); 
0
source

The only way to get complete control over it is with WebWorkers.

Basically you create xhr.worker.js, which only has an HTTP request to download the image (it gets the URL through the message).

After loading the image, the image will be in the browser cache, so you just need to set src = '' to the image URL to show it.

If you kill a particular web artist, image upload will also be canceled!

0
source

All Articles