JavaScript Issue with Dynamic Image Gallery

I’m designing a website for Reborn Auto Body, and I’m running into an issue with a JavaScript feature.Has anyone encountered this problem before or have any advice on how to resolve it?

I’ve set up a dynamic gallery to showcase before-and-after images of car repairs, but the images aren’t loading correctly when switching between categories. Initially, everything loads fine, but when I click on a different category, some images don’t appear until I refresh the page. I’m using vanilla JavaScript and think it might be an issue with event listeners or caching.