Ziggeo/ziggeo-client-sdk

Mutation observers always added and still run when app instance has been destroyed

Closed this issue · 4 comments

We have noticed that just by loading the ziggeo.js file on the page adding of any dom nodes are slowed down (noticable mostly when adding alot at the same time).

It would be nice if these mutation observers could be removed or at least optional? What are they needed for? If they can't be made optional maybe they can be added only when the app is instantiated and then removed when the app instance is destroyed?

Hi Mattias,

Can you tell us what version of our client SDK are you using? I am guessing that this might be related to some recent updates to the resizing of our embeddings (player and recorders), however in different revisions we have made different changes, and in some there are also fixes for couple of such changes..

So knowing more about it would help :)

HI @emattias, we are using these observers to look for embeds that are embedded to the page via HTML. That is, embeds that look similar to this:
<ziggeorecorder></ziggeorecorder>
<ziggeoplayer ziggeo-video="TOKEN"></ziggeo-player>

You can disable those observers by adding the following code on the page header (before the ziggeo.js script):

<script>window.ZiggeoDefer = true;</script>

Note: doing this will stop components that are embedded via HTML from working. If you want to enable these observers later on you can do it by calling:

ZiggeoApi.V2.Application.undefer();

By the way, if you are embedding using the JS method you don't need these observers. 🙂
Here is an example of a recorder embedded using JS:

var recorder = new ZiggeoApi.V2.Recorder({
    element: document.querySelector("#recorder"),
    attrs: {
        // ...
    }
});
recorder.activate();

Hi Mattias,

Can you tell us what version of our client SDK are you using? I am guessing that this might be related to some recent updates to the resizing of our embeddings (player and recorders), however in different revisions we have made different changes, and in some there are also fixes for couple of such changes..

So knowing more about it would help :)

@Bane-D This happens with the latest stable version: ziggeo-client-sdk - v2.39.16 - 2022-01-24 (and I also tried r34)

HI @emattias, we are using these observers to look for embeds that are embedded to the page via HTML. That is, embeds that look similar to this: <ziggeorecorder></ziggeorecorder> <ziggeoplayer ziggeo-video="TOKEN"></ziggeo-player>

You can disable those observers by adding the following code on the page header (before the ziggeo.js script):

<script>window.ZiggeoDefer = true;</script>

@ntshcalleia Thanks! This works! Is this documented anywhere?

Hi Mattias, thank you for confirming that it is working.

Is this documented anywhere? (defer and undefer)

We are using it in some scenarios, however it is not documented as of yet. Generally it is used to defer the application initialization and is not recommended. It is great that it also removes html observers as well helping you in this case.

The reason for not documenting: you have to know to add this every time in proper way, and if you do not document it internally your colleagues would likely have issues running the service. So for most of our customers this is not something that would be recommended.

Next to the above, we have on our list of optimizations to remove the need for some scripts that are running (and not needed) as we look to have optimized service so at some point this will not be needed :)

Since it is working for you, I will mark this as closed, please feel free to reopen if needed.