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:
OffscreenCanvas is 50% faster at creation
Text operations on OffscreenCanvas are 15–45% faster.
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.
Sorry, just realised I created this with the wrong GitHub account (there's an ugly mismatch between the committer and the creator of the PR). I'll recreate this with the correct account.
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:OffscreenCanvas
is 50% faster at creationOffscreenCanvas
are 15–45% faster.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.