Are you sure you want to go to an external site to donate a monetary value?
WARNING: Some countries laws may supersede the payment processors policy such as the GDPR and PayPal. While it is highly appreciated to donate, please check with your countries privacy and identity laws regarding privacy of information first. Use at your utmost discretion.
I need help making image loading better.
Concerning to userscript Newspaper.
Since document is processed while is "on load" (aka "on the fly"), I want to replace all attributes of
srctosrc-datawhile program processes the document.I've attempted to do so by adding to function
renderFeedthe following code which doesn't work for all images, or is it? (I might need to check again)for (const image of newDocument.querySelectorAll('img')) { //source = image.src; //image.removeAttribute('src'); //image.setAttribute('src-data', source); image.setAttribute('src-data', image.src); image.removeAttribute('src'); }Yet, below the execution of code
document.replaceChild(insertDocument,removeDocument);I've added this code:for (const image of document.querySelectorAll('img')) { image.addEventListener('mouseover', loadImage(image)) image.onmouseover = () => { image.removeEventListener('mouseover',loadImage(image)) } }Which causes the infinite loop if the line of function
loadImageis not commented out.function loadImage(image) { console.log('onmouseover') source = image.getAttribute('src-data'); image.removeAttribute('src-data'); image.src = source; //image.removeEventListener('mouseover',loadImage(image)) // This line causes infinite loop. }Note that I use
mouseoverevent so it would be easier to test, though I want the event to trigger when animageelement is inside or close to viewport.P.S.
"Provident Image Load" (PIL) is a better name, eh?
Much better than the stupid phrase "Lazy (so called) Load".