DEV Community

Discussion on: Loading Images with Web Workers

Collapse
 
cikaldev profile image
Ian Cikal

Hi Trez, thank you for the article..

Correct me if i'm wrong, in Step 6 you write this,

// Get the original element for this image
const imageElement = document.querySelectorAll(`img[data-src='${imageData.imageURL}']`)
Enter fullscreen mode Exit fullscreen mode

but the images never showing. instead i have the error message inside console setAttribute() is not a function ... after change into this one, the errors gone and images showing. :)

// the problem is located at "querySelector()"
const imageElement = document.querySelector(`img[data-src='${imageData.imageURL}']`)
Enter fullscreen mode Exit fullscreen mode

If you have a time please update the sample code, for future reader,
Again thank you for the article.