Created
September 1, 2024 06:54
-
-
Save erdum/8b65ad1a16511367b0b40223d8c8fdfa to your computer and use it in GitHub Desktop.
Large image loader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
const largeImageUrl = '/path/to/large-image.jpg'; | |
const bodyElement = document.querySelector('body'); | |
const largeImage = new Image(); | |
largeImage.src = largeImageUrl; | |
largeImage.onload = () => { | |
bodyElement.style.backgroundImage = `url(${largeImageUrl})`; | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment