---
title: "Comment by Minnel H on \"Image optimization for static NextJS sites\" | Hashnode"
description: "Hi Iva Kop. Thanks for your article. It will be really helpful for many developers. 👏 I am trying to optimize all images that use on the website developed by n"
url: "https://hashnode.com/posts/image-optimization-for-static-nextjs-sites/604cae1e37d84907f1327f94/comment/610cfbc3528eff11aea87552"
---

[Discussion](https://hashnode.com/posts/image-optimization-for-static-nextjs-sites/604cae1e37d84907f1327f94)

Comment [Image optimization for static NextJS sites](https://hashnode.com/posts/image-optimization-for-static-nextjs-sites/604cae1e37d84907f1327f94)

[Minnel H](https://hashnode.com/@HDreamDev)

[Aug 6, 2021](https://hashnode.com/posts/image-optimization-for-static-nextjs-sites/604cae1e37d84907f1327f94/comment/610cfbc3528eff11aea87552)

Hi Iva Kop. Thanks for your article. It will be really helpful for many developers. 👏 I am trying to optimize all images that use on the website developed by next js. For exporting into HTML, I used the "next-optimized-images" package. It works correctly with static require (e.g: require('/src/demo.png') as your above article. But for all of the Images, I have to import images with require dynamically (e.g: const imagePath = '/src/demo.png'; require(imagePath) in a loop ). If I debug the imagePath variable its value is correct but it does not work. I know we can not use the "require" dynamically, if so is there any other way to run the package("next-optimized-images")? Could you help me or advise anything? 🙏 Thanks. Minnel.

[Iva Kop](https://hashnode.com/@IvaKop)

[Sep 28, 2021](https://hashnode.com/posts/image-optimization-for-static-nextjs-sites/604cae1e37d84907f1327f94/comment/610cfbc3528eff11aea87552#reply-615327159c8bfd08f5ba746c)

Hi Minnel! The topic seems to be discussed in [this GitHub issue](https://github.com/cyrilwanner/next-optimized-images/issues/16). Hope it helps!

[Minnel H](https://hashnode.com/@HDreamDev)

[Sep 28, 2021](https://hashnode.com/posts/image-optimization-for-static-nextjs-sites/604cae1e37d84907f1327f94/comment/610cfbc3528eff11aea87552#reply-6153a1ea414f78089df3b8ca)

[Iva Kop](https://hashnode.com/@IvaKop) Hi Iva Kop. Thanks for your comment. 😍
