mirror of
https://github.com/alexandrev/xslt-lab.git
synced 2026-09-16 18:23:16 +00:00
Fix blog mobile LCP: only load adsbygoogle.js when inArticleSlot is set
adsbygoogle.js (28KB) + consent framework (126KB + 32KB) were loading on every blog page despite inArticleSlot being empty — no ads shown, 186KB of JS downloaded for nothing. Mobile LCP: 11.1s → expected ~2-3s. Keep the google-adsense-account meta tag for account verification. Script now conditional on both client AND slot being configured. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
{{- $client := .Site.Params.adsense.client -}}
|
||||
{{- $slot := .Site.Params.adsense.inArticleSlot -}}
|
||||
{{- if and $client (ne hugo.Environment "development") -}}
|
||||
<meta name="google-adsense-account" content="{{ $client }}">
|
||||
{{- if $slot -}}
|
||||
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client={{ $client }}" crossorigin="anonymous"></script>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user