borgar / textbox

Library to layout text for display on SVG or Canvas.
Other
26 stars 6 forks source link

Use OffscreenCanvas when available #27

Closed flother closed 2 years ago

flother commented 2 years ago

A Google Chrome Developers session from 2019 states that OffscreenCanvas has better performance than <canvas> even when it's running on the main thread. Their benchmarks showed that:

The second benchmark is of the most value to this library. It's a bit of a micro-optimisation, but it will have benefits if a lot of text measurement is going on.

OffscreenCanvas is available in Chrome and Edge (since 2018 and 2020 respectively). Other browsers will continue to use <canvas> to measure text.