diff --git a/apps/comments-ui/src/index.js b/apps/comments-ui/src/index.js index bb43242983..dc35c44b5a 100644 --- a/apps/comments-ui/src/index.js +++ b/apps/comments-ui/src/index.js @@ -7,20 +7,18 @@ const ROOT_DIV_ID = 'ghost-comments-root'; function addRootDiv() { const scriptTag = document.querySelector('script[data-ghost-comments]'); - if (process.env.NODE_ENV === 'development') { + // We need to inject the comment box at the same place as the script tag + if (scriptTag) { + const elem = document.createElement('div'); + elem.id = ROOT_DIV_ID; + scriptTag.parentElement.insertBefore(elem, scriptTag); + } else if (process.env.NODE_ENV === 'development') { const elem = document.createElement('div'); elem.id = ROOT_DIV_ID; document.body.appendChild(elem); } else { - // We need to inject the comment box at the same place as the script tag - if (scriptTag) { - const elem = document.createElement('div'); - elem.id = ROOT_DIV_ID; - scriptTag.parentElement.insertBefore(elem, scriptTag); - } else { - // eslint-disable-next-line no-console - console.warn('Comment box location was not found: could not load comments box.'); - } + // eslint-disable-next-line no-console + console.warn('Comment box location was not found: could not load comments box.'); } }