Skip to content
This repository has been archived by the owner on Jan 9, 2021. It is now read-only.

Minify HTML #84

Open
kangax opened this issue Feb 22, 2015 · 3 comments · May be fixed by #87
Open

Minify HTML #84

kangax opened this issue Feb 22, 2015 · 3 comments · May be fixed by #87

Comments

@kangax
Copy link

kangax commented Feb 22, 2015

I ran the entire page through my html-minifier — ES6 spec seems like a perfect candidate for it.

Here's the result:

Size before Size after Savings
3765813 (3677.55 KB) 3132089 (3058.68 KB) 16.83% (618.87 KB)
434781 (424.59 KB) 382709 (373.74 KB) 11.98% (50.85 KB)

Second colum is (more representative) gzipped comparison. So it's pure savings of 50KB (already accounting for gzip which is how the page is transferred) and it only takes ~3 sec to minify it as a one-time task.

There should be no differences in rendering.

What do you think? Worth it?

@jorendorff
Copy link
Owner

If this is a 2-line change to the go script, sure, I'll take a PR for it.

Rationale: OK, this is just barely worth it. Even in pessimistic circumstances, the 12% savings might mean the difference between waiting 1 minute for the whole document and waiting 1 minute 7 seconds; or it might mean the difference between having a 35% chance of successfully downloading the whole document vs. a 40% chance.

Changing the Python script to spit out minified HTML could likely be done by deleting code, rather than adding it, but an external tool is better. The output from es-spec.py is pretty-printed on purpose. That way I can use git diff es6-draft.html to see if the output seems sane, and sometimes get a feel for what's changed.

Honestly, there are other ideas I'd rather see pursued to improve the download speed: change the script to generate multipage output, or a hypothetical fancy new JS-powered page that downloads the text incrementally. Maybe Markdown output, which would be more compact than HTML. But I'll take what I can get!

@mathiasbynens
Copy link
Contributor

Re: multipage output, ref. #5.

@mathiasbynens
Copy link
Contributor

@jorendorff To install the HTML minifier dependency using npm:

npm install html-minifier -g

Then, every time you build a new version of es6-draft.html, run this command:

html-minifier --collapse-whitespace --remove-attribute-quotes --remove-redundant-attributes --prevent-attributes-escaping --use-short-doctype --remove-optional-tags es6-draft.html > es6-draft-minified.html

I can submit a PR that adds this info to the README, but it might be better to create a build.sh or Makefile that includes this command and recommend using that in the README.

mathiasbynens added a commit to mathiasbynens/es-spec-html that referenced this issue Mar 8, 2015
@mathiasbynens mathiasbynens linked a pull request Mar 8, 2015 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants