You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to minify the script in production environments? I think the script just needs to be injected in another way so gatsby can handle the script itself.
<scriptid="simple-analytics-loader" type="text/javascript" data-loaded="false">!(function(s,i,m,p,l,e){constparent=document.querySelector('#simple-analytics-loader');if(!parent)return;constdnt=s.doNotTrack||m.doNotTrack||m.msDoNotTrack;if(/yes|1/.test(dnt)&&parent){parent.setAttribute('data-enabled',false);returnconsole.warn('Simple Analytics: Not loading script when doNotTrack is enabled');}l=i.createElement(p);l.addEventListener('load',function(){if(parent){parent.setAttribute('data-loaded',true);letevent;if(typeofEvent==='function'){event=newEvent('script-loaded');}else{event=document.createEvent('Event');event.initEvent('script-loaded',true,true);}parent.dispatchEvent(event);}},false)l.async="true";l.src="https://scripts.simpleanalyticscdn.com/latest.js";l.type="text/javascript";l.setAttribute('id','simple-analytics');e=i.getElementsByTagName(p)[0];e.parentNode.insertBefore(l,e);})(window,document,navigator,'script')</script></html>
The text was updated successfully, but these errors were encountered:
No, sorry. I have asked the Gatsby community (in Discord) but got no response yet. If there is no way I think using terser to minify it first would do the job as well. Since plugins are mostly at build time this would just increase the building time (I don't think significantly).
Coming back to it; I think the only way is to use terser before "loadScript" and minify the script. I would say this is OK, since the script isn't that big it wouldn't increase the build time significantly. Another approach would be to have this script in a script-tmpl.js which gets minified and outputted into src as load-script.js at release time. Then the script would be already minified in the npm release.
Would it be possible to minify the script in production environments? I think the script just needs to be injected in another way so gatsby can handle the script itself.
The text was updated successfully, but these errors were encountered: