@shopgate/engage
Version:
Shopgate's ENGAGE library.
6 lines • 805 B
JavaScript
import appConfig from'@shopgate/pwa-common/helpers/config';import{initCSSCustomProps,initCSSCustomPropsFallback}from"./initCSSCustomProperties";/**
* Loads external CSS with custom properties
* @returns {void}
*/export var loadCustomStyles=function loadCustomStyles(){var id='external-css';var href=appConfig.customStyleUrl;var linkTag=document.querySelector("#".concat(id));/**
* Error handler
*/var onError=function onError(){initCSSCustomPropsFallback();};if(!href){onError();}if(href&&!linkTag){linkTag=document.createElement('link');linkTag.setAttribute('rel','stylesheet');linkTag.setAttribute('type','text/css');linkTag.setAttribute('href',href);linkTag.setAttribute('id',id);linkTag.onload=initCSSCustomProps;linkTag.onerror=onError;document.querySelector('head').appendChild(linkTag);}};