Should browsers automatically receive images when src is dynamically redefined without ajax?

I noticed that when the image source attribute changes dynamically (in my case, using jQuery), even if the image was never called / cached by the browser (that is, it was not preloaded), the browser still selects this - and without ajax. This works for me in all 5 major browsers (i.e. 7+).

Question: Is this a formally standardized behavior that I could count on forever?

+3
source share
2 answers

The DOM has two behaviors called reflow and repaint that will force its elements to be redrawn (colors, sizes). These behaviors are triggered whenever the “input information used to build the rendering tree” changes in the DOM (there is a nice description of all this: rendering: repaint, reflow / relayout, restyle )

For your question, when this is called, browsers will also try to extract src links, including javascript; therefore, we can dynamically embed scripts / link styles, and the DOM will execute it.

. , CSS , , . DOM , . src .

+3

, , jQuery, (dom), ( img).

IE6.

+2

All Articles