T
T
Torvolf2020-08-19 14:27:31
WordPress
Torvolf, 2020-08-19 14:27:31

How to delay the loading of metrics scripts on wordpress?

Maybe someone knows how to delay the download or completely remove the Yandex metrics, google analytics, facebook, etc. scripts from the download. Because of them, PageSpeed ​​sags a lot. And if Yandex, then it’s clear how it can be excluded from the download, then for example fb apparently comes directly from the VP topic and I can’t understand how to exclude it. Ideally, it would probably just be to delay loading them.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan Hasanli, 2020-08-19
@Torvolf

fb apparently comes directly from the topic vp

install query monitor, find handle of this script, do dequeue or deregister.
Maybe someone knows how to delay the download or completely remove the Yandex metrics, google analytics, facebook, etc. scripts from the download.

Usually, to optimize for PageSpeed, I include these scripts locally. The PHP script downloads these files locally (scheduled script launch via CRON), and the scripts are already connected locally. Then PageSpeed ​​doesn't complain...

I
IvanMogilev, 2020-08-19
@IvanMogilev

what you connect directly can be hidden from bots like this

if (!isset($_SERVER['HTTP_USER_AGENT']) || stripos($_SERVER['HTTP_USER_AGENT'], 'Lighthouse')

in functions.php, respectively, where you connect scripts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question