loading-attribute-polyfill icon indicating copy to clipboard operation
loading-attribute-polyfill copied to clipboard

Dynamic image list

Open chumanfu opened this issue 4 years ago • 2 comments

Hi.

Div which is hidden until the user click a button. I only load the images on the at the time I click the button. This appears to cause the images not to render, I am guessing because the polyfill has already been performed on the images. Is there a way of progmatically calling the polyfill after the images are drawn in the div?

chumanfu avatar Mar 01 '21 10:03 chumanfu

@chumanfu thanks a lot for your request. I've just released a beta of the new version 2.0 that would provide this feature - you could install it via npm i loading-attribute-polyfill@beta Than there's a public method that you might call with a query for each of the related DOM nodes, like e.g.: loadingAttributePolyfill.prepareElement(document.querySelector('main noscript.loading-lazy'));

Do you have the chance to check this out regarding your usecase?

mfranzke avatar Mar 04 '21 20:03 mfranzke

@mfranzke thanks for the polyfill. adding images dynamically seems to be broken. you can see this by visiting the demo url and clicking on the "Add dynamic image underneath" button while looking at the network tab. the dynamically added image is immediately downloaded without the need to scroll down. is there any workaround to fix this?

parto avatar Feb 09 '22 03:02 parto