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: 4-binary/03-blob/article.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
`Blob`# Blob
1
+
# Blob
2
2
3
3
`ArrayBuffer` and views are a part of ECMA standard, a part of JavaScript.
4
4
@@ -89,7 +89,7 @@ link.click();
89
89
URL.revokeObjectURL(link.href);
90
90
```
91
91
92
-
`URL.createObjectURL` takes a `Blob` and creates an unique URL for it, in the form `blob:<origin>/<uuid>`.
92
+
`URL.createObjectURL` takes a `Blob` and creates a unique URL for it, in the form `blob:<origin>/<uuid>`.
93
93
94
94
That's what the value of `link.href` looks like:
95
95
@@ -101,11 +101,11 @@ The browser for each URL generated by `URL.createObjectURL` stores an the URL ->
101
101
102
102
A generated URL (and hence the link with it) is only valid within the current document, while it's open. And it allows to reference the `Blob` in `<img>`, `<a>`, basically any other object that expects an url.
103
103
104
-
There's a side-effect though. While there's an mapping for a `Blob`, the `Blob` itself resides in the memory. The browser can't free it.
104
+
There's a side-effect though. While there's a mapping for a `Blob`, the `Blob` itself resides in the memory. The browser can't free it.
105
105
106
-
The mapping is automatically cleared on document unload, so `Blob`o bjects are freed then. But if an app is long-living, then that doesn't happen soon.
106
+
The mapping is automatically cleared on document unload, so `Blob`objects are freed then. But if an app is long-living, then that doesn't happen soon.
107
107
108
-
**So if we create an URL, that `Blob` will hang in memory, even if not needed any more.**
108
+
**So if we create a URL, that `Blob` will hang in memory, even if not needed any more.**
109
109
110
110
`URL.revokeObjectURL(url)` removes the reference from the internal mapping, thus allowing the `Blob` to be deleted (if there are no other references), and the memory to be freed.
111
111
@@ -119,7 +119,7 @@ An alternative to `URL.createObjectURL` is to convert a `Blob` into a base64-enc
119
119
120
120
That encoding represents binary data as a string of ultra-safe "readable" characters with ASCII-codes from 0 to 64. And what's more important -- we can use this encoding in "data-urls".
121
121
122
-
A [data url](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) has the form `data:[<mediatype>][;base64],<data>`. We can use such urls everywhere, on a par with "regular" urls.
122
+
A [data url](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) has the form `data:[<mediatype>][;base64],<data>`. We can use such urls everywhere, on par with "regular" urls.
0 commit comments