Useful code for optimizing Pagespeed
10.11.2025 (18:02)
10.11.2025
A little useful technique in the feed, for those who constantly lose 10-15 Pagespeed points after hanging Yandex.Metrics on their ideal sites in the purest code.
Just use my code, which only loads the metric when you're scrolling a page or clicking, and then Pagespeed doesn't see it, and doesn't deduct points. I'm already putting just such code on all sites, no problems have been observed. Yes, some spam visits and refusals may not be recorded, but we don't need them? Here's the code itself:
<script>
(function() {
let loaded = false;
function loadYandexMetrika() {
if (loaded) return;
loaded = true;
setTimeout(function() {
(function(m,e,t,r,i,k,a){
m[i]=m[i]||function(){(m[i].a=m[i].a|[]).push(arguments)};
m[i].l=1*new Date();
k=e.createElement(t),a=e.getElementsByTagName(t)[0],
k.async=1,k.src=r,a.parentNode.insertBefore(k,a)
})(window, document, «script», «https://mc.yandex.ru/metrika/tag.js«The »Box»
The author of the post is not listed
© dice.expert - Marketing SEO Directory