partytown icon indicating copy to clipboard operation
partytown copied to clipboard

[🐞] High Total Blocking Time (TBT) using Google Analytics and partytown

Open benmccann opened this issue 8 months ago • 5 comments

Describe the bug

Screenshot from 2023-12-26 09-05-03

Screenshot from 2023-12-15 22-33-37

I don't know if this is purely unavoidable. However, it surprised me as I thought Partytown was supposed to move all computations off the main thread.

My page speed score is a couple of points better without Partytown + GA. However, Partytown + GA is still several points better than GA alone.

Reproduction

https://partytown.builder.io/google-tag-manager

Steps to reproduce

Setup Google Analytics with Partytown. E.g. I followed https://partytown.builder.io/sveltekit

Then use https://pagespeed.web.dev/ (look under "Avoid long main-thread tasks") or https://webpagetest.org/ to see that Partytown is significantly blocking the main thread.

Browser Info

Chrome

Additional Information

No response

benmccann avatar Dec 16 '23 06:12 benmccann

Looks like Lighthouse has gotten stricter on its scoring. That amount of blocking time is now taking 7 points of the Lighthouse score

Screenshot from 2024-01-09 08-09-52

benmccann avatar Jan 09 '24 16:01 benmccann

Can you try with the new release pls? Thanks

gioboa avatar Jan 09 '24 21:01 gioboa

Thank you for taking a look. Unfortunately no improvement

Screenshot from 2024-01-09 14-13-37

benmccann avatar Jan 09 '24 22:01 benmccann

Here is my result. This is your website, right?

Screenshot 2024-01-09 at 23 36 36

gioboa avatar Jan 09 '24 22:01 gioboa

Yes, that's my site that I've been testing with. The overall score is somewhat variable with some runs doing better than others. Obviously the site scores well overall, but I can't help but want to get to 100 :grin: Probably the most useful piece to look at rather than the overall score is the "Avoid long main-thread tasks" section and see whether Partytown is listed there as contributing to Total Blocking Time. My expectation was that Partytown shouldn't block, but I have limited insight into the internals, so perhaps there's some reason it's not possible for Partytown to operate in a non-blocking way.

benmccann avatar Jan 10 '24 21:01 benmccann