Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/natemoo-re/tiny-decode
Decode HTML entities the browser-friendly way
https://github.com/natemoo-re/tiny-decode
Last synced: 18 days ago
JSON representation
Decode HTML entities the browser-friendly way
- Host: GitHub
- URL: https://github.com/natemoo-re/tiny-decode
- Owner: natemoo-re
- License: mit
- Created: 2023-01-09T16:58:27.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-09T20:10:53.000Z (almost 2 years ago)
- Last Synced: 2024-10-05T14:01:05.905Z (29 days ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 18
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `tiny-decode`
Decoding [HTML named character references](https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references) traditionally requires a large table to store entity names and the code points to which they refer. Unless you take extreme care, this data can easily end up in your JavaScript bundle.
`tiny-decode` takes advantage of [export conditions](https://nodejs.org/api/packages.html#packages_conditional_exports) to include only as much JavaScript as necessary. For bundled browser code, the `decode` function is only a few bytes. For server-side code, `decode` includes the full [`entities`](https://github.com/fb55/entities) module, which is much larger.
## Example
```
Bundle `entities` 18.52 kB │ gzip: 19.64 kB
Bundle `tiny-decode` 0.97 kB │ gzip: 0.56 kB
```