From 685a6f36d9609868d5f7d8d479d1d873d4219f6f Mon Sep 17 00:00:00 2001 From: Pete Davison Date: Mon, 25 Dec 2023 22:44:38 +0000 Subject: [PATCH] fix: only attempt to attach ad if sidebar ad container exists --- docs/static/js/carbon.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/static/js/carbon.js b/docs/static/js/carbon.js index f18744a2..4b7ebae2 100644 --- a/docs/static/js/carbon.js +++ b/docs/static/js/carbon.js @@ -1,17 +1,20 @@ (function () { function attachAd() { - var el = document.createElement('script'); - el.setAttribute('type', 'text/javascript'); - el.setAttribute('id', '_carbonads_js'); - el.setAttribute( - 'src', - '//cdn.carbonads.com/carbon.js?serve=CESI65QJ&placement=taskfiledev' - ); - el.setAttribute('async', 'async'); - var wrapper = document.getElementById('sidebar-ads'); - wrapper.innerHTML = ''; - wrapper.appendChild(el); + if (wrapper) { + + var el = document.createElement('script'); + el.setAttribute('type', 'text/javascript'); + el.setAttribute('id', '_carbonads_js'); + el.setAttribute( + 'src', + '//cdn.carbonads.com/carbon.js?serve=CESI65QJ&placement=taskfiledev' + ); + el.setAttribute('async', 'async'); + + wrapper.innerHTML = ''; + wrapper.appendChild(el); + } } setTimeout(function () {