Load third-party scripts after Lighthouse / Page Speed Insights scan finishes

502 Views Asked by At

My website has some third-party scrips that affect badly on website's LCP score (Marked as "Reduce unused JavaScript").
The main one is Hotjar.
My target is to load this script after Lighthouse / Page Speed Insights finishes it's scan (I don't mind to loose some seconds when the script doesn't work).
I tried to use tricks like defer, load event, etc... Nothing seems to be work.
Has someone faced this issue? How can I handle it without using hard-coded settimout?
Thanks :)

0

There are 0 best solutions below