DOM Ready

There is no need for an on-DOM-ready handler in Dart. Dart makes the sane decision of deferring evaluation until the DOM is ready for processing.

Actually, Dart takes this a step further. Dart allows one <script> tag of type application/dart with one main entry point. This one entry point is what is invoked when the DOM is ready.

Folks coming from the craziness of JavaScript with an infinite number of <script> tags and execution contexts may be feeling a desperate sense of constriction at this point. But after a deep breath or two, cooler heads should be able to admit that an infinite number of scripts all running at essentially the same time usually wind up causing more trouble than they are worth. Besides, Dart does allow for multiple, isolated execution environments, as you’ll see in Chapter 14, Futures and Isolates.

Be wary of compiling Dart to JavaScript and then expecting <script> tags that point to this compiled JavaScript to work. We will talk about how Dart’s JavaScript compiler maintains this single, main entry point in the next chapter, Chapter 5, Dart and JavaScript.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.199.181