Improve consensus-health page by reducing size of HTML
Problem:
The consensus-health page @ https://consensus-health.torproject.org/ is currently ~ 5.4 MB uncompressed (231 KB over the wire, using gzip). The large size of the uncompressed document makes browser rending take longer than it needs to, consumes excess RAM, and (probably) consumes excess CPU cycles on the server during compression, or excess bandwidth when served uncompressed.
Specifics:
- Redundant content:
a. 25,862 instances of '(.?)'
a. 5,068 instances of '
(.?)' a. 2,200 instances of '(.*?)' - Unnecessary elements:
a. Headers in relay list use '(.*?)' for bolding when changing the '' to '' would give the same presentation for less bytes, while being more semantically correct HTML. (8,256 instances)
a. Headers in relay list use '
' before each DirAuth name in order to provide spacing (8,256 instances) - Unnecessary white space: a. 572,662 instances of a. 97,899 instances of '\n' between (not inside) tags.
- Reduce redundant content:
a. Remove '' for each individual flag, and set ' class="ic"' on the column instead. Add appropriate CSS. Estimated savings: 600 KB
a. Replace '
' with ''. Add appropriate CSS. Estimated savings: 40 KB a. Replace '' with ''. Add appropriate CSS. Estimated savings: This is actually a small net loss, but by changing to it will match the other changes and compress more efficiently. - Remove unnecessary elements:
a. Remove all '' and '
' tags from the relay list headers. Set ' class="tbl-hdr"' on the and change '' to ''. Add height and vertical alignment to CSS. Estimated savings: 77 KB - Remove unnecessary white space:
a.
- Replace each with "\t". '''Estimated savings: 570 KB'''
- OR: Remove all instances of entirely. '''Estimated savings: 1.1 MB'''
- OR: Replace the white space with a variable that can be enabled when white space is desired (for debuging purposes). ''' Estimated savings: 1.1 MB''' a. newline
- Remove all newlines after block/table-related elements. ''' Estimated savings: 95 KB'''
- OR: Replace newlines with variable that can be enabled for debugging purposes. '''Estimated savings: 95 KB'''
Proposal:
Implement the following changes, which reduce the document size without affecting its presentation:
By implementing the above changes, the consensus-relay could be trimmed by up to 1.9 MB -- a full 1/3 of it's 5.4 MB bulk. Since part 3 could be controversial, I'll put that in a separate patch (assuming it is wanted). I'm attaching a patch that implements parts 1 and 2. It should trim the uncompressed document by around 700 KB.
Trac:
Username: alphawolf