I would like to know if it is possible to unload an image from an HTML page and free its memory occupation with some Javascript instructions. Say an image is already display
You can free memory of an img element by assigning the src attribute to a 1x1 pixel before removing it.
const imgElement = document.querySelector(selector); imgElement.setAttribute('src', '/images/pixel.gif'); imgElement.parentElement.removeChild(imgElement);