From 132d6ba50c5717e2b043348bff7002863eea8a3d Mon Sep 17 00:00:00 2001 From: Anthony Date: Fri, 10 Dec 2021 15:26:04 +0100 Subject: [PATCH] only load ima when needed --- ui/component/app/view.jsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ui/component/app/view.jsx b/ui/component/app/view.jsx index 48431a112..9eb4a73bc 100644 --- a/ui/component/app/view.jsx +++ b/ui/component/app/view.jsx @@ -7,7 +7,7 @@ import classnames from 'classnames'; import analytics from 'analytics'; import { setSearchUserId } from 'redux/actions/search'; import { buildURI, parseURI } from 'util/lbryURI'; -import { SIMPLE_SITE } from 'config'; +import { SIMPLE_SITE, SHOW_ADS } from 'config'; import Router from 'component/router/index'; import ModalRouter from 'modal/modalRouter'; import ReactModal from 'react-modal'; @@ -346,15 +346,17 @@ function App(props: Props) { // Load IMA3 SDK for aniview useEffect(() => { - const script = document.createElement('script'); - script.src = imaLibraryPath; - script.async = true; - // $FlowFixMe - document.body.appendChild(script); - return () => { + if (!isAuthenticated && SHOW_ADS) { + const script = document.createElement('script'); + script.src = imaLibraryPath; + script.async = true; // $FlowFixMe - document.body.removeChild(script); - }; + document.body.appendChild(script); + return () => { + // $FlowFixMe + document.body.removeChild(script); + }; + } }, []); // add secure privacy script