Just removing from the DOM. childNode.remove()
The ChildNode.remove() method removes the object from the tree it belongs to. node.remove(); Here is div-01 Here is…
The browser has its own additional image cache that it manages itself (and stores large amounts on the local disk of the user). When you create a new image element for an image that exists in the browser cache, it is clever enough to use it rather than send a new network request. It will still trigger the load events on the images (regardless of whether it filled from cache or network) which means you can write your code the same and trust the browser will do its thing.
At one point we tried to be extra clever and had our own cache, where we removed the images from the DOM but kept references to them in memory so we could shuttle them back in later, but it turned out to have no appreciable impact on performance (actually some downsides in garbage collection and memory usage) so we dropped it.
So this code is as simple as created a new Image element (actually we may be using DIVs with background-image and the background-size: cover) for things that should be visible, and then just the native remove (and obviously also drop any references to them in memory, eg in arrays) once done.