You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2-ui/5-loading/03-onload-onerror/article.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -113,13 +113,13 @@ This rule also affects resources from other domains.
113
113
114
114
If we're using a script from another domain, and there's an error in it, we can't get error details.
115
115
116
-
For example, let's take a script with a single (bad) function call:
116
+
For example, let's take a script `error.js` that consists of a single (bad) function call:
117
117
```js
118
118
// 📁 error.js
119
119
noSuchFunction();
120
120
```
121
121
122
-
Now load it from our domain:
122
+
Now load it from the same site where it's located:
123
123
124
124
```html run height=0
125
125
<script>
@@ -155,15 +155,15 @@ Script error.
155
155
, 0:0
156
156
```
157
157
158
-
Details may vary depending on the browser, but the idea is same: any information about the internals of a script is hidden. Exactly because it's from another domain.
158
+
Details may vary depending on the browser, but the idea is same: any information about the internals of a script, including error stack traces, is hidden. Exactly because it's from another domain.
159
159
160
-
Why do we need the details?
160
+
Why do we need error details?
161
161
162
-
There are many services (and we can build our own) that listen to `window.onerror`, save errors at the server and provide an interface to access and analyze them. That's great, as we can see real errors, triggered by our users. But we can't see any error information for scripts from other domains.
162
+
There are many services (and we can build our own) that listen to global errors using `window.onerror`, save errors and provide an interface to access and analyze them. That's great, as we can see real errors, triggered by our users. But if a script comes from another origin, then there's no much information about errors in it, as we've just seen.
163
163
164
164
Similar cross-origin policy (CORS) is enforced for other types of resources as well.
165
165
166
-
**To allow cross-origin access, we need`crossorigin` attribute, plus the remote server must provide special headers.**
166
+
**To allow cross-origin access, the `<script>` tag needs to have`crossorigin` attribute, plus the remote server must provide special headers.**
0 commit comments