Events

As mentioned, JavaScript is not an object-oriented language; neither, in a strict sense, is an HTML page. The DOM puts an object interface on an HTML page, but inherently it is still a document. JavaScripts embedded in an HTML page inherently suffer from some of the same problems. Like the document itself, JavaScript is read and interpreted in the order it appears in the document. Any script blocks that contain executable JavaScript statements outside of a function definition are interpreted in the order they are read. Writing in-line scripts that initialize the page before the user starts to interact with it might be OK to write this way, although I still wouldn't encourage it.

A more structured way to organize JavaScripts in an HTML ...

Get Building Web Applications with UML Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.