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

Layout batching #259

Merged
merged 2 commits into from Jul 25, 2015
Merged

Layout batching #259

merged 2 commits into from Jul 25, 2015

Conversation

omo
Copy link
Contributor

@omo omo commented Jul 22, 2015

This change speeds up the loading time in some scenarios where

  • The test string is long thus the layout computation can be expensive,
  • The font comes from the local file system (including the browser cache) thus network latency isn't dominant, and
  • On a mobile device whose CPU is slow

The app we're developing sees 10% speedup for the font loading time with this change.

omo added 2 commits July 22, 2015 16:03
Neither webfont.FontWatchRunner.fontRulerC_ nor
webfont.FontWatchRunner.LastResortFonts.MONOSPACE
doesn't seem to be used. Let's remove it.
Changing the ruler's font while computing the width forces
browsers to run the layout computation multiple times, which is
sometimes expensive.

This change gives each last resort font its own ruler, eliminates
the font changes in start(). This allows browsers to compute the
layout less often, save the overhead surrounding the layout routine.
@omo
Copy link
Contributor Author

omo commented Jul 24, 2015

@bramstein Would you mind taking a look at this as well? This is for browsers without native font loading API. The speedup is not that big, but still worth having IMO.

@bramstein
Copy link
Contributor

These look like good changes. On which browsers have you seen the speedup? So what we're changing now is replacing modifying an existing DOM element with inserting more DOM elements?

@omo
Copy link
Contributor Author

omo commented Jul 24, 2015

Yes, it adds extra DOM node to get rid of updating the style of existing node. By doing this, we can follow "create DOM once, then layout it at once" pattern which reduces the number of layout invocations.

I'm using Chrome for Android and Chromium based WebView on Android. Also, the product I'm working on has to use much longer test string as it sometimes uses non-latin fonts. That's a big reason why the layout time matters.

@bramstein
Copy link
Contributor

Excellent, I'll merge this in and do a release. Thanks a lot!

@omo
Copy link
Contributor Author

omo commented Jul 24, 2015

Thanks a lot! And let me be annoying here - What about #260 ?

bramstein added a commit that referenced this pull request Jul 25, 2015
@bramstein bramstein merged commit d41bda6 into typekit:master Jul 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants