From e8d86d93d2928f2dd18a1c00e0b02342accc4041 Mon Sep 17 00:00:00 2001 From: Ghost-017 <31908292+Ghost-017@users.noreply.github.com> Date: Sat, 19 Oct 2019 20:09:37 +0800 Subject: [PATCH] minor --- 2-ui/5-loading/03-onload-onerror/article.md | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/2-ui/5-loading/03-onload-onerror/article.md b/2-ui/5-loading/03-onload-onerror/article.md index d83548a7..9490d1dd 100644 --- a/2-ui/5-loading/03-onload-onerror/article.md +++ b/2-ui/5-loading/03-onload-onerror/article.md @@ -1,6 +1,6 @@ # Resource loading: onload and onerror -The browser allows to track the loading of external resources -- scripts, iframes, pictures and so on. +The browser allows us to track the loading of external resources -- scripts, iframes, pictures and so on. There are two events for it: @@ -49,11 +49,11 @@ script.onload = function() { So in `onload` we can use script variables, run functions etc. -...And what if the loading failed? For instance, there's no such script (error 404) or the server or the server is down (unavailable). +...And what if the loading failed? For instance, there's no such script (error 404) or the server is down (unavailable). ### script.onerror -Errors that occur during the loading of the script can be tracked on `error` event. +Errors that occur during the loading of the script can be tracked in an `error` event. For instance, let's request a script that doesn't exist: @@ -69,12 +69,12 @@ script.onerror = function() { */!* ``` -Please note that we can't get HTTP error details here. We don't know was it error 404 or 500 or something else. Just that the loading failed. +Please note that we can't get HTTP error details here. We don't know if it was an error 404 or 500 or something else. Just that the loading failed. ```warn Events `onload`/`onerror` track only the loading itself. -Errors during script processing and execution are out of the scope of these events. To track script errors, one can use `window.onerror` global handler. +Errors during script processing and execution are out of scope for these events. To track script errors, one can use `window.onerror` global handler. ``` ## Other resources @@ -98,7 +98,7 @@ img.onerror = function() { There are some notes though: -- Most resources start loading when they are added to the document. But `` is an exception. It starts loading when it gets an src `(*)`. +- Most resources start loading when they are added to the document. But `` is an exception. It starts loading when it gets a src `(*)`. - For `