Google 广告脚本正在降低 Google 页面速度指数得分
Google ads scripts are decreasing Google page speed index score
是否有解决方案在页面加载后加载 Google 脚本,从而 google 页面速度指数没有受到影响?
此代码对繁重的 javascript 代码设置了超时,如果用户滚动它也会 运行 因此内容会显示得更快
var scrollCounter = false;
var pageType = typeof signal !== 'undefined' && signal.Content.ArticleId!=null?'article':'notanarticle';
var cds = /Mobi/.test(navigator.userAgent) && document.body.clientWidth < 737 ? 'Mobile' : /Mobi/.test(navigator.userAgent) && document.body.clientWidth > 767 ? 'Tablet' : 'Desktop';
if (cds == 'Mobile') {
//condition for home and section pages
if(pageType == 'notanarticle') {
setTimeout(function() {
if (!scrollCounter) {
scrollCounter = true;
console.log('timeout');
addThirdPartyLibs();
}
}, 4000);
}//end of condition
var activityEvents = [
'keydown', 'touchstart', 'scroll'
];
activityEvents.forEach(function(eventName) {
document.addEventListener(eventName, function(e) {
if (!scrollCounter) {
scrollCounter = true;
console.log(window.scrollY);
addThirdPartyLibs();
}
}, true);
});
} else {
addThirdPartyLibs();
}
function addThirdPartyLibs() {
loadGPTJs();
}
是否有解决方案在页面加载后加载 Google 脚本,从而 google 页面速度指数没有受到影响?
此代码对繁重的 javascript 代码设置了超时,如果用户滚动它也会 运行 因此内容会显示得更快
var scrollCounter = false;
var pageType = typeof signal !== 'undefined' && signal.Content.ArticleId!=null?'article':'notanarticle';
var cds = /Mobi/.test(navigator.userAgent) && document.body.clientWidth < 737 ? 'Mobile' : /Mobi/.test(navigator.userAgent) && document.body.clientWidth > 767 ? 'Tablet' : 'Desktop';
if (cds == 'Mobile') {
//condition for home and section pages
if(pageType == 'notanarticle') {
setTimeout(function() {
if (!scrollCounter) {
scrollCounter = true;
console.log('timeout');
addThirdPartyLibs();
}
}, 4000);
}//end of condition
var activityEvents = [
'keydown', 'touchstart', 'scroll'
];
activityEvents.forEach(function(eventName) {
document.addEventListener(eventName, function(e) {
if (!scrollCounter) {
scrollCounter = true;
console.log(window.scrollY);
addThirdPartyLibs();
}
}, true);
});
} else {
addThirdPartyLibs();
}
function addThirdPartyLibs() {
loadGPTJs();
}