Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize order of attributes #4

Closed
kangax opened this issue May 17, 2010 · 7 comments
Closed

Normalize order of attributes #4

kangax opened this issue May 17, 2010 · 7 comments

Comments

@kangax
Copy link
Owner

kangax commented May 17, 2010

This might result in better gzip compression.

@hsablonniere
Copy link

We need to group most used attributes of each elements together. Can it be computed, maybe...

@kangax
Copy link
Owner Author

kangax commented Jun 3, 2013

Do you mean computing gzip savings? Which order results in better compression?

@duncanbeevers
Copy link
Collaborator

Once the gzip benchmark stuff lands, it'll be much easier to see whether efforts in this area yield size savings.

@duncanbeevers
Copy link
Collaborator

We can try simplistic approaches like alphabetizing attributes, or more sophisticated approaches like identifying which tag/attribute combos occur most-often. For example, determining that div tag's most-common attribute is class while span tag's most-common attribute it id, resulting in better encoding of <div class= and <span id= sequences.

@kangax
Copy link
Owner Author

kangax commented Aug 20, 2014

We can try simplistic approaches like alphabetizing attributes

Yeah, I imagine after gzip it's probably mostly insignificant, since afaik gzip already does some sort of optimal reordering?

For example, determining that div tag's most-common attribute is class while span tag's most-common attribute it id, resulting in better encoding of <div class= and <span id= sequences.

Yep. Sounds reasonable.

@alexlamsl
Copy link
Collaborator

So if I understand correctly, we scan through a given tag name collecting statistics, then re-order the attributes by descending frequency?

Most of the time only shuffling the most frequently-used attribute to the front would suffice, but then if that attribute happens to have the same value across then we can form a longer chain if we perform reordering on the rest as well...

@kangax
Copy link
Owner Author

kangax commented Mar 31, 2016

Sounds about right :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants