1

I have an overridden GWT DialogBox that has as a widget overridden PagingScrollTable. I have something like this in my code:

1) DialogBox dialog = new ...
2) dialog.center(); 
3) Window.alert("Hello"); 

In IE I would see alert after loading of table’s header but before loading of table’s content (about 1000 rows). But javascript is single-threaded language so how can it be? May it be a browser issue or issue of my code?

Thanks!

2 Answers 2

1

Javascript may be single-threaded, but the browser isn't, and page rendering is not done by the Javascript engine, so there's no conflict that Javascript can be running while the page is rendering.

(in fact, you can add the async attribute on the <script> tag to tell the browser explicitly to do this, although sadly this attribute isn't fully supported in all browsers yet)

Sign up to request clarification or add additional context in comments.

1 Comment

but isn't it strange that while borwser renders previous DOM changes caused by js, js flow goes further? Can I catch events that corresponds to rendering?
0

Javascript is asynchronous (and it runs inside a thread in the browser so it's not in lock-step with the page loading the way you might think it is. Once the javascript itself is loaded, it need only be triggered by an event to run, or, the fact that it's loaded is enough to run it. '' tag contents are processed by the browser instantly - so if you have code that isn't wrapped in a 'function' that you bind to 'unload' or something similar - it'll just run whenever it shows up in the DOM.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.