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

Switch opencollective images to self-hosted spritesheet #4318

Merged
merged 12 commits into from Jun 10, 2020

Conversation

Munter
Copy link
Member

@Munter Munter commented Jun 8, 2020

After we added all our opencollective sponsors and backers to the documentation, the load time and the total download size of the documentation increased significantly. It can easily take several seconds to finish loading the opencollective images, despite them being on a CDN served on http2.

This network graph for our current situation looks like this:

1_waterfall_thumb

There is no way for a user to opt out of downloading these 256 images at about 700kb in total.

  • We should increase the speed of download, since these images are literally the first thing people see when visiting the documentation
  • We should reduce the amount of bytes downloaded

Description of the Change

The opencollective fetcher script now downloads all sponsor logos and avatar images in order to self-host. A sprite sheet post process is added in order to reduce the amount of requests and further lossy compression is applied.

  • Fetch full images and store them. Previously we fetched the first chunk only to figure out dimensions
  • Change supporters template to use self-hosted images
  • Add a spritesheet definition to make assetgraph-builder sprite the self-hosted images
  • Apply lossy compression to the sprite sheet: pngquant 256 colors. Reduces the download size by approximately 8x
  • Remove avatar.js, since sprite sheets are background images that don't trigger onload events
  • Filtered out personal backers that specifically have asked to be anonymous

Improvements:

  • Reduced download size by about 500kb
  • Faster time to final render with backer images
  • Less CPU time usage (due to removal of JS to image loaded animation)

Here's a before and after comparison: https://www.webpagetest.org/video/compare.php?tests=200607_Z2_58f219880cacb17ae211d74b8e670c1c,200608_DX_cd846fd4961c94ad247dab95eaac76d8-r%3A1-c%3A0&thumbSize=200&ival=500&end=full

image

image

image

image

Alternate Designs

We could self host the individual images, but speed measurements showed less improvement than a sprite sheet.

Benefits

Faster time to final rendering of the top part of the documentation. Significantly less downloaded bytes

Possible Drawbacks

The backer image loading animation is replaced by a slightly less appealing raw image loading progress. On the other hand it's much faster.

@Munter Munter added area: documentation anything involving docs or mochajs.org type: chore generally involving deps, tooling, configuration, etc. labels Jun 8, 2020
Copy link
Member

@boneskull boneskull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if it's ready

.gitignore Outdated Show resolved Hide resolved
docs/_includes/supporters.md Outdated Show resolved Hide resolved
… Caused render flush that resulted in confusing layout shift on reload
@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.578% when pulling be128cb on munter/sprite-opencollective-avatars into a2f2e08 on master.

@boneskull boneskull self-requested a review June 10, 2020 18:32
Copy link
Member

@boneskull boneskull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm again. @Munter merge at your convenience; it's not clear to me if you're finished with this one.

@Munter Munter merged commit fc618a1 into master Jun 10, 2020
@Munter Munter deleted the munter/sprite-opencollective-avatars branch June 10, 2020 19:03
@boneskull boneskull added this to the next milestone Jul 29, 2020
@boneskull boneskull added the semver-patch implementation requires increase of "patch" version number; "bug fixes" label Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: documentation anything involving docs or mochajs.org semver-patch implementation requires increase of "patch" version number; "bug fixes" type: chore generally involving deps, tooling, configuration, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants