Events

As was mentioned before, JavaScript is not an objected-oriented language, and in a strict sense, neither is an HTML page. The DOM puts an object interface on an HTML page, but it is inherently still a document. JavaScript embedded in an HTML page inherently suffers from some of these 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 JavaScript ...

Get Building Web Applications with UML 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.