TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Modern strategies for achieving 60fps on the web?

8 pointsby makeitreinover 4 years ago
Happy Presidents Day HN - taking the day off to hack on a side project of mine - not quite sure what the pitch is yet, but it&#x27;s a whiteboardy &#x2F; mindmappy tool - here&#x27;s a recent deploy of mine to show off some of the basic WIP features - https:&#x2F;&#x2F;tile-shift-c5nkbkutr.vercel.app&#x2F;<p>My inner Steve Jobs is getting a bit annoyed that when I pan around, I can&#x27;t achieve 60fps reliably. You&#x27;ll especially notice the choppiness if you pan around a lot of cards. I understand that I could easily get to that frame speed had I chosen to build with canvas or WebGL, but the DOM is a much happier technology to work with.<p>The crux of the problem is that I have one event listener that fires on every mousemove event to pan the canvas... it&#x27;s not the most expensive calculation, but it fires quite a bit, causing the browser to constantly spend some time scripting and re-rerendering.<p>What&#x27;s strange is that when I plug in my external monitor, that choppiness disappears. According to my webdev friends, external monitors force your browser to use GPU acceleration for everything, regardless if the browser is viewed on the external monitor or laptop.<p>I found this surprising! It begs the question... why can&#x27;t my app use GPU acceleration for everything?<p>Given that context, do you have any advice that could help me achieve 60fps? Is GPU acceleration worth exploring, or is that barking up the wrong tree?

2 comments

throwaway888abcover 4 years ago
&gt;event listener that fires on every mousemove event to pan the canvas... it&#x27;s not the most expensive calculation, but it fires quite a bit, causing the browser to constantly spend some time scripting and re-rerendering.<p>Look at &quot;Throttling and Debouncing Events&quot;, you don&#x27;t need to process every single event as humans are not that accurate. It will make you application perceived much more smoothly.<p>Article about the concept.<p><a href="https:&#x2F;&#x2F;www.digitalocean.com&#x2F;community&#x2F;tutorials&#x2F;vuejs-lodash-throttle-debounce" rel="nofollow">https:&#x2F;&#x2F;www.digitalocean.com&#x2F;community&#x2F;tutorials&#x2F;vuejs-lodas...</a><p>Next point to consider is using web worker thread for calculation and not blocking main thread. Another article about the concept,<p><a href="https:&#x2F;&#x2F;medium.com&#x2F;launch-school&#x2F;what-are-web-workers-4a0e1ded7a67" rel="nofollow">https:&#x2F;&#x2F;medium.com&#x2F;launch-school&#x2F;what-are-web-workers-4a0e1d...</a><p>Have fun
speedgooseover 4 years ago
Use requestAnimationFrame, you can definitely do 60fps with a canvas, and much better like 144fps or more if your screen supports it.<p>If your laptop is a bit slow, you will also get better results if you connect its plug so it doesn&#x27;t run on the battery on energy saving mode.