javascript - How to force loading images for the webpages installed "lazy load" without scrolling? -
i implement chrome extension. extension needs images urls of webpages. however, webpages have "lazy load" plug-in. question if possible can still urls without required manually scrolling down?
many of lazy-load plugins stores actual url in data-* section. when scrolling down, right before image tag gets view data-* content set on src
attribute start loading image.
you can iterate through image tags find links, example:
var images = document.queryselectorall("img"), links = [], = 0, img; while(img = images[i++]) links.push(img.dataset.original || img.src);
but note there no naming standard data-* holder different plugins use different names - you'll have collect these manually (f.ex. this plugin uses name data-original
, this one uses data-layzr
, on).
you possible addition step looping through dataset
collection find string may seem contain url (if src
empty), prone errors images same server relative links , data-* can hold other data too.
Comments
Post a Comment