Hi, I've searched through the channel but can't fi...
# ask-questions
l
Hi, I've searched through the channel but can't find a solution to my issue. I'm loading the SDK via GTM. And i've added very basic piece of code to load the value of the feature. All of this works. I do see large delays, after I pushed the custom code and the actual execution. I've added timestamps to my code. sdk added 0ms custom code loaded 85ms queue pushed 6964ms check feature on 7994ms So between 85ms and 6964ms the gb object is loading before at 6964ms it processes the queue. How can I improve the performance of this? (I have this both on the cloud as when using the self hosted version.) This is the custom code.
Copy code
window.growthbook_queue.push(function(gb) {
    console.log("queue pushed", Date.now()-window.gb_start);
    function applyFeatureFlags() {
      if(gb.isOn("logo-bg-color")) {
        console.log("check feature on", Date.now()-window.gb_start);
      }
    }
    // Call your function initially plus whenever new data is received
    applyFeatureFlags();
    document.addEventListener("growthbookdata", applyFeatureFlags)
  });
console.log('code loaded', Date.now() - window.gb_start);
f
that is a very long time
that doesn't sound right
How are you loading GrowthBook via GTM?
l
Yes via GTM, the "sdk added" is when the tag is loaded
<script> window.gb_start = Date.now(); (function(s) { s=document.createElement('script'); s.async=true; s.dataset.clientKey="xxxxx"; s.dataset.apiHost="http://localhost:3300"; s.src="https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/auto.min.js"; document.head.appendChild(s); })(); console.log("sdk added", Date.now() - window.gb_start); </script>
f
do you have an option of not using GTM?
l
I'll give it a try on a simple empty html page first without the rest of our website loading.
We are using react and our application is pretty heavy, this might be causing delays.
i'll try a blank page first
f
ok
l
On a blank page I get better timings. Is this more realistic? sdk added 0 code loaded 22 queue pushed 1589 check feature on 2011
f
the SDK fetch should be about 20ms
everything else is local, so that seems okay
not sure why the queue push is so long -is there something in the dom?
like is it huge?
its less so the timings - growthbook doesn't really add much to your load- but more making sure that your experiments/features are going to load at the right time
you don't want to have a flicker
do you have a CDN by any chance? if you do, you can use edge workers to run the SDK and save time
l
When I directly add my code in the html page, I get quick responses. https://tools.tadaaz.com/test/growthbook.html
When I do it via tagmanger I get a delay between sdk load an queue push execution. I'm going to see if we can implement the growthbook directly in our webapplication. We plan to do serverside testing in the future with our react app, but need to look into the impact of that on our caching. We are using AWS as environment
Thx for your quick response! awesome!
It seems that gtm debug mode is at least adding 1500ms delay. When container is published it gets way faster. code loaded 32ms sdk added 34ms queue pushed 54ms check feature on 55ms