This commit is contained in:
Ilya Kantor 2019-05-23 07:56:42 +03:00
parent 7f1d5de09e
commit bdda1af6b0
2 changed files with 5 additions and 5 deletions

View file

@ -1,6 +1,6 @@
# Hello, world! # Hello, world!
The tutorial that you're reading is about core JavaScript, which is platform-independent. Later on, you'll learn about Node.js and other platforms that use it. This part of the tutorial is about core JavaScript, the language itself. Later on, you'll learn about Node.js and other platforms that use it.
But we need a working environment to run our scripts and, since this book is online, the browser is a good choice. We'll keep the amount of browser-specific commands (like `alert`) to a minimum so that you don't spend time on them if you plan to concentrate on another environment (like Node.js). We'll focus on JavaScript in the browser in the [next part](/ui) of the tutorial. But we need a working environment to run our scripts and, since this book is online, the browser is a good choice. We'll keep the amount of browser-specific commands (like `alert`) to a minimum so that you don't spend time on them if you plan to concentrate on another environment (like Node.js). We'll focus on JavaScript in the browser in the [next part](/ui) of the tutorial.

View file

@ -3,13 +3,13 @@
The lifecycle of an HTML page has three important events: The lifecycle of an HTML page has three important events:
- `DOMContentLoaded` -- the browser fully loaded HTML, and the DOM tree is built, but external resources like pictures `<img>` and stylesheets may be not yet loaded. - `DOMContentLoaded` -- the browser fully loaded HTML, and the DOM tree is built, but external resources like pictures `<img>` and stylesheets may be not yet loaded.
- `load` -- the browser loaded all resources (images, styles etc). - `load` -- not onyl HTML is loaded, but also all the external resources: images, styles etc.
- `beforeunload/unload` -- when the user is leaving the page. - `beforeunload/unload` -- the user is leaving the page.
Each event may be useful: Each event may be useful:
- `DOMContentLoaded` event -- DOM is ready, so the handler can lookup DOM nodes, initialize the interface. - `DOMContentLoaded` event -- DOM is ready, so the handler can lookup DOM nodes, initialize the interface.
- `load` event -- additional resources are loaded, we can get image sizes (if not specified in HTML/CSS) etc. - `load` event -- external resources are loaded, so styles are applied, image sizes are known etc.
- `beforeunload` event -- the user is leaving: we can check if the user saved the changes and ask them whether they really want to leave. - `beforeunload` event -- the user is leaving: we can check if the user saved the changes and ask them whether they really want to leave.
- `unload` -- the user almost left, but we still can initiate some operations, such as sending out statistics. - `unload` -- the user almost left, but we still can initiate some operations, such as sending out statistics.