javascript - how to change src of an img element even before the DOM loads -


i wondering if there exists carousel has bunch of images shown user, lets based on user, img shown in carousel needs change else. how can 1 change img src, before page loads? dom not exist dom element img element , change src new image? how can 1 it?

i thinking may have inline script tag within head section async set false not block loading of dom. not sure. please let me know if there other alternatives or html5 features

you can't use javascript access dom before loaded. best way deal compile html on server-side using templating language handlebars (depends on backend language is). however, if isn't option put place-holder loading symbol in place of image , dynamically add src url once <img> has loaded in dom , use js or jquery change src attribute.

hope helps!


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -