https://github.com/peterbe/optimize-titles.json
Ideas for optimizing the titles.json files in Yari
https://github.com/peterbe/optimize-titles.json
mdn
Last synced: 7 months ago
JSON representation
Ideas for optimizing the titles.json files in Yari
- Host: GitHub
- URL: https://github.com/peterbe/optimize-titles.json
- Owner: peterbe
- Created: 2020-07-15T17:41:09.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-15T18:18:52.000Z (over 5 years ago)
- Last Synced: 2025-01-29T03:35:39.943Z (9 months ago)
- Topics: mdn
- Language: Python
- Homepage: https://docs.google.com/spreadsheets/d/1e6yDVtXJXqUr5J__a1OpVbp7YurvG_942vmZBtTH1uU/edit#gid=0
- Size: 353 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# optimize titles.json
In [Yari](https://github.com/mdn/yari), as a build step we produce a
`build/$locale/titles.json` file which get downloaded, with XHR, in
the browser so it matters that it's not unnecessarily big which means
due to network speed would be bad user experience.## To run the experiment
Run:
python 1.py # generates 1.json
python 2.py # genetates 2.csv
python 3.py # generates 4.json
python 4.py # generates 4.jsonProduce the table with:
python table.py
Or just use `ls`:
ls -ltrS
## Results
One version of the results as of today:

Exclusively `gzip` sizes:

Just the `.gz` versions:
```bash
▶ ls -ltrS *.gz
-rw-r--r-- 1 peterbe staff 155639 Jul 15 14:05 5.json.gz
-rw-r--r-- 1 peterbe staff 158917 Jul 15 12:05 4.json.gz
-rw-r--r-- 1 peterbe staff 195261 Jul 15 11:59 2.csv.gz
-rw-r--r-- 1 peterbe staff 209658 Jul 15 11:56 1.json.gz
-rw-r--r-- 1 peterbe staff 213309 Jul 15 12:00 3.json.gz
-rw-r--r-- 1 peterbe staff 213342 Jul 15 11:54 0.json.gz
```And pretty-printed sizes:
```bash
▶ ls -ltrSh *.gz
-rw-r--r-- 1 peterbe staff 152K Jul 15 14:05 5.json.gz
-rw-r--r-- 1 peterbe staff 155K Jul 15 12:05 4.json.gz
-rw-r--r-- 1 peterbe staff 191K Jul 15 11:59 2.csv.gz
-rw-r--r-- 1 peterbe staff 205K Jul 15 11:56 1.json.gz
-rw-r--r-- 1 peterbe staff 208K Jul 15 12:00 3.json.gz
-rw-r--r-- 1 peterbe staff 208K Jul 15 11:54 0.json.gz
```## Conclusion
The cheapest thing you can do is to round the `popularity` numbers down to
fewer significant figures. And to omit the `popularity` when it's 0 anyway
doesn't hurt.