DEV Community

[Comment from a deleted post]
Collapse
 
daviddalbusco profile image
David Dal Busco

My interpretation is that when you apply any change to the DOM the browser has to evaluates / renders it. Generally it is really performant, super fast and almost instant but, in that particular case or often with sizes too, it took a few more milliseconds.

Collapse
 
gaurav5430 profile image
Gaurav Gupta

i do't think it should depend on how much time the browser takes. The browser has to model this as a synchronous or async functionality. if it is synchronous, the browser would wait for these changes to be applied before evaluating the next line. if it is asynchronous, then it would always be async and you can't expect it sometimes evaluate the next line in time amd sometimes not.

 
daviddalbusco profile image
David Dal Busco

sorry what I meant, I interpret the browser painting operations as async (the operations which happen inside the browser, not javascript).

 
gaurav5430 profile image
Gaurav Gupta

yeah, you are right, the paint / rendering operation is asynchronous, but regular dom manipulation is not. I think the manipulation here using execCommand might be asynchronous, which is why you need to wait.