Skip to content

Commit 7895f3d

Browse files
committed
minor
1 parent eca29f5 commit 7895f3d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

6-async/01-callbacks/article.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ The call initiates the script loading, then the execution continues. While the s
2929

3030
```js
3131
loadScript('/my/script.js');
32-
// the code below doesn't wait for the script loading to finish
32+
// the code below loadScript doesn't wait for the script loading to finish
33+
// ...
3334
```
3435

3536
Now let's say we want to use the new script when it loads. It probably declares new functions, so we'd like to run them.
@@ -44,7 +45,7 @@ newFunction(); // no such function!
4445
*/!*
4546
```
4647

47-
Naturally, the browser probably didn't have time to load the script. As of now, `loadScript` function doesn't provide a way to track the load completion. The script loads and eventually runs, that's all. But we'd like to know when happens, to use new functions and variables from that script.
48+
Naturally, the browser probably didn't have time to load the script. So the immediate call to the new function fails. As of now, `loadScript` function doesn't provide a way to track the load completion. The script loads and eventually runs, that's all. But we'd like to know when happens, to use new functions and variables from that script.
4849

4950
Let's add a `callback` function as a second argument to `loadScript` that should execute when the script loads:
5051

@@ -150,7 +151,7 @@ function loadScript(src, callback) {
150151

151152
*!*
152153
script.onload = () => callback(null, script);
153-
script.onerror = () => callback(new Error(`Script load error ` + src));
154+
script.onerror = () => callback(new Error(`Script load error for ${src}`));
154155
*/!*
155156

156157
document.head.append(script);

0 commit comments

Comments
 (0)