这是我为测试cookie同意代码的影响而创建的非常基本的html.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="test page speed">
<title>Speed test 1</title>
<meta content="width=device-width, initial-scale=1" name="viewport">
<link href="favicon.png" rel="shortcut icon" type="image/x-icon">
<!-- BEGIN Cookie Consent -->
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "#eee",
"text": "#000"
},
"button": {
"background": "#0f0",
"text": "#ffffff"
}
}
})});
</script>
<!-- END Cookie Consent -->
</head>
<body class="body">
<h1>Hello!</h1>
<p>
This is a test.
</p>
</body>
</html>
如果没有Cookie同意部分,FCP为0.8秒(根据Google的PageSpeed Insights测量).
对于Cookie同意部分,FCP为1.9秒.性能大幅下降!
如何才能在1秒左右返回FCP?