【发布时间】:2020-12-03 10:22:20
【问题描述】:
我在 html.js 文件的 html.js 文件中添加了这样的 head 标签
const ads = process.env.NODE_ENV === "production" && (
<script
async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"
/>
)
return (
<html {...props.htmlAttributes}>
<head>
<meta charSet="utf-8" />
<meta httpEquiv="x-ua-compatible" content="ie=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css"
/>
{props.headComponents}
{ads && ads}
</head>
<body {...props.bodyAttributes}>
{props.preBodyComponents}
<div
key={`body`}
id="___gatsby"
dangerouslySetInnerHTML={{ __html: props.body }}
/>
{props.postBodyComponents}
</body>
</html>
如果有任何方法可以提高网站的性能,我将不胜感激。 因为当我添加这个脚本标签时,我的网站性能变得非常糟糕。
【问题讨论】: