Skip to content

Commit b5a0865

Browse files
committed
minor
1 parent 87c7b45 commit b5a0865

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

1-js/11-async/01-callbacks/article.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22

33
# Introduction: callbacks
44

5+
```warn header="We use browser methods here"
6+
To demonstrate the use of callbacks, promises and other abstract concepts, we'll use browser methods. Namely, load scripts and perform simple document manipulations.
7+
8+
If you're not familiar with them, please read few chapters from the [next part](/document) of the tutorial.
9+
10+
Or, maybe examples will be clear enough for you even without that.
11+
```
12+
513
Many actions in JavaScript are *asynchronous*.
614

7-
For instance, take a look at the function `loadScript(src)`:
15+
For instance, we can schedule such actions using `setTimeout`.
16+
17+
There are other real-world examples of asynchronous actions, e.g. take a look at the function `loadScript(src)`, that should load a new script with the given `src`:
818

919
```js
1020
function loadScript(src) {
@@ -14,18 +24,18 @@ function loadScript(src) {
1424
}
1525
```
1626

17-
The purpose of the function is to load a new script. When it adds the `<script src="…">` to the document, the browser loads and executes it.
27+
When it appends the new, dynamically created, tag `<script src="…">` to the document, the browser loads and executes it.
1828

19-
We can use it like this:
29+
We can use this function like this:
2030

2131
```js
22-
// loads and executes the script
32+
// load and execute the script at the given path
2333
loadScript('/my/script.js');
2434
```
2535

26-
The function is called "asynchronously," because the action (script loading) finishes not now, but later.
36+
The script is executed "asynchronously", because script loading finishes not right now, but later.
2737

28-
If there's a code below `loadScript(…)`, it doesn't wait until the loading finishes.
38+
If there's a code below `loadScript(…)`, it doesn't wait until the script loading finishes.
2939

3040
```js
3141
loadScript('/my/script.js');
@@ -34,7 +44,7 @@ loadScript('/my/script.js');
3444
// ...
3545
```
3646

37-
We'd like to use the new script as soon as it loads. It declares new functions, and we want to run them.
47+
Let's say we need to use the new script as soon as it loads. It declares new functions, and we want to run them.
3848

3949
But if we do that immediately after the `loadScript(…)` call, that wouldn't work:
4050

0 commit comments

Comments
 (0)