Skip to content

Commit 5445aa0

Browse files
authored
fix(adsense): push ad slot once only on dev (#276)
1 parent 017a86b commit 5445aa0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/runtime/components/ScriptGoogleAdsense.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,18 @@ const instance = useScriptGoogleAdsense({
3535
3636
const { status } = instance
3737
38+
function pushAdSlot() {
39+
(window.adsbygoogle = window.adsbygoogle || []).push({})
40+
}
41+
3842
onMounted(() => {
39-
callOnce(() => {
40-
(window.adsbygoogle = window.adsbygoogle || []).push({})
41-
})
43+
if (import.meta.dev) {
44+
callOnce(() => pushAdSlot())
45+
}
46+
else {
47+
pushAdSlot()
48+
}
49+
4250
watch(status, (val) => {
4351
if (val === 'loaded') {
4452
emits('ready', instance)

0 commit comments

Comments
 (0)