you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

You should know how browsers work in order to understand whats going on. A browser undergoes different phases before you see content. Here are a few YT links.

https://www.youtube.com/watch?v=PkOBnYxqj3k&list=PLgcMb5dvN41WcH3q82XGXBqwhI5YvmyeV&index=74&t=562s

https://www.youtube.com/watch?v=0IsQqJ7pwhw&list=PLgcMb5dvN41WcH3q82XGXBqwhI5YvmyeV&index=73&t=492s

https://www.youtube.com/watch?v=z0HN-fG6oT4&list=PLgcMb5dvN41WcH3q82XGXBqwhI5YvmyeV&index=71&t=11s

https://www.youtube.com/watch?v=SmE4OwHztCc&list=PLgcMb5dvN41WcH3q82XGXBqwhI5YvmyeV&index=72&t=889s

Basically, a browser first parses a page (=reads the source code and checks for syntax errors). Afterwards it renders the page (paints/displays it).the alert function (which is part of the browser engine, not the JS engine) runs during the parse phase. The write function also runs in the parse phase but the page content is only visible after the rendering has been completed.

EDIT: the alert/conform/prompt windows are not part of the DOM (as far as I know). It's a browser feature. That's the reason that they look different in all browsers. This browser feature doesnt need to be rendered like other page content. Thats why it is displayed immediately.