pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/javascript-tutorial/en.javascript.info/pull/3941/files

hubassets.com/assets/primer-primitives-10bf9dd67e3d70bd.css" /> fix: correct events related terms in fetch-api article.md en by front42 · Pull Request #3941 · javascript-tutorial/en.javascript.info · GitHub
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 5-network/06-fetch-api/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ For example, we gather statistics on how the current visitor uses our page (mous

When the visitor leaves our page -- we'd like to save the data to our server.

We can use the `window.onunload` event for that:
For that we can use the `unload` event on the `window` object:

```js run
window.onunload = function() {
Expand All @@ -218,7 +218,7 @@ Normally, when a document is unloaded, all associated network requests are abort
It has a few limitations:

- We can't send megabytes: the body limit for `keepalive` requests is 64KB.
- If we need to gather a lot of statistics about the visit, we should send it out regularly in packets, so that there won't be a lot left for the last `onunload` request.
- If we need to gather a lot of statistics about the visit, we should send it out regularly in packets, so that by the time of the `unload` event there won't be much left to send.
- This limit applies to all `keepalive` requests together. In other words, we can perform multiple `keepalive` requests in parallel, but the sum of their body lengths should not exceed 64KB.
- We can't handle the server response if the document is unloaded. So in our example `fetch` will succeed due to `keepalive`, but subsequent functions won't work.
- In most cases, such as sending out statistics, it's not a problem, as the server just accepts the data and usually sends an empty response to such requests.
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy