What if I use js before DOM rendering?

for example, I want to change the src before the img tag is rendered. If I write the js at the end of the body, the image will be sent two different requests for two different images.
I want to change this address before src sends the request. How can I do this?

Jun.09,2022

you can write two img tags and use a variable to show and hide the two img,display:none or block


you can write

like this.
<img data-src="" />

then use js to change the value of src, so that the request will only be sent once

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be9dbe-319a7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be9dbe-319a7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?