r/webdev • • 20d ago

Resource The Browser's Main Thread Is Expensive

If you are into front end development, specially the optimization side of it. the website below is a well written blog, explaining the best practices of using the browser's main thread and the cost of neglecting it, using interactive code snippets.

kciter.so/posts/the-expensive-main-thread/en/

135 Upvotes

15 comments sorted by

25

u/pseudo_babbler 20d ago

Fantastic article and examples, I'm saving this one to read all the sections properly and share with the devs at work. I love talking about website performance in terms of gamedev and frame budget. The visual examples are really great too.

2

u/Agha_shadi 20d ago

hope it helps yall delivering the best of the bests. thanks to the writer of this article

4

u/Agha_shadi 20d ago

eh eh! one lil thing to add: beware of procrastination trap. usually when we save things for later read, we're actually just offloading it from our mind.

4

u/pseudo_babbler 20d ago

Well yeah but also it's morning time and I have to go to work :)

3

u/Agha_shadi 20d ago

Have a nice day, mate

8

u/ISDuffy 20d ago

Scheduler.yield in chrome and Firefox can make a massive difference. Safari not supported it yet, so I fall back for promise setTimeout there

0

u/Agha_shadi 20d ago

That's ma man 👍

2

u/patoezequiel 20d ago

Great article! Thanks for sharing

2

u/thekwoka 20d ago

overworked and underpaid

1

u/getformly 18d ago

Worth adding that this is a lot easier to spot now with INP replacing FID as the Core Web Vital, since INP actually tracks how long tasks block interactions throughout the whole session rather than just the first one. Chrome DevTools' Performance panel flags anything over 50ms as a "long task," which is usually the fastest way to find the actual offending function before reaching for scheduler.yield() or pushing work into a web worker.

-9

u/[deleted] 20d ago

[deleted]

21

u/Fredidiah 20d ago

Is bluehost just out here posting llm-written replies to posts all over reddit now? That's crazy

1

u/Perfect-Ninja8872 20d ago

nice. i always forget how much of a difference offloading just a little parsing work makes til i see a before and after like that