# Support for SPAs / error when reloading (quick fix!)

**URL:** <https://devforum.zoom.us/t/support-for-spas-error-when-reloading-quick-fix/60875>\
**Category:** Web\
**Created:** [November 30, 2021, 2:30pm UTC](https://devforum.zoom.us/t/support-for-spas-error-when-reloading-quick-fix/60875 "2021-11-30T14:30:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitcrush-robin](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@bitcrush-robin](https://devforum.zoom.us/u/bitcrush-robin)\
**Post date:** [November 30, 2021, 2:30pm UTC](https://devforum.zoom.us/t/support-for-spas-error-when-reloading-quick-fix/60875/1 "2021-11-30T14:30:41Z")

</div>

**Description**  
I’ve been working on getting the web sdk working inside a Single Page Application style site. Because the ZoomMtg object creates the #zmmtg-root element when it’s loaded, I made it only load the SDK on the vue-routed page which needs it.

I have it destroying/unloading the ZoomMtg object when the user navigates away, but when they navigate back again, there are some issues with Object.defineProperty things that the `zoomus-websdk.umd.min.js` file applies.

These are Array.prototype.uniquelize, Array.prototype.union, and Array.prototype.minus.

The quick fix is to match other is-this-set checks in the same file , e.g. `Array.prototype.union || Object.defineProperty(Array.prototype,"union"` …

The better fix would be to mark all of the properties as configurable, and add a ZoomMtg.unload to unset them all, among other things. The even better fix would be to allow deferred activation too, so I can load the sdk with my other javascript!

**Browser Console Error**  
Uncaught TypeError: Cannot redefine property: uniquelize  
at Function.defineProperty ()

**Which Web Meeting SDK version?**  
2.0.1

**Meeting SDK Code Snippets**  
node\_modules/@zoomus/websdk/dist/zoomus-websdk.umd.min.js, prettified

```auto
Array.prototype.intersect || Object.defineProperty(Array.prototype, "intersect", {
    enumerable: !1,
    value: function() {
        for (var e = new Array, t = {}, n = 0; n < arguments.length; n++)
            for (var r = 0; r < arguments[n].length; r++) {
                var o = arguments[n][r];
                t[o] ? (t[o]++,
                t[o] === arguments.length && e.push(o)) : t[o] = 1
            }
        return e
    }
}),
Object.defineProperty(Array.prototype, "uniquelize", {
    enumerable: !1,
    value: function() {
        for (var e = {}, t = [], n = 0, r = this.length; n < r; n++)
            e[this[n]] || (e[this[n]] = 1,
            t.push(this[n]));
        return t
    }
}),
String.prototype.startsWith || Object.defineProperty(Array.prototype, "startsWith", {
    enumerable: !1,
    value: function(e, t) {
        return t = t || 0,
        this.indexOf(e, t) === t
    }
}),
Object.defineProperty(Array.prototype, "union", {
    enumerable: !1,
    value: function() {
        for (var e = new Array, t = {}, n = 0; n < arguments.length; n++)
            for (var r = 0; r < arguments[n].length; r++) {
                var o = arguments[n][r];
                t[o] || (t[o] = 1,
                e.push(o))
            }
        return e
    }
}),
Object.defineProperty(Array.prototype, "minus", {
    enumerable: !1,
    value: function(e) {
        for (var t = new Array, n = {}, r = 0; r < e.length; r++)
            n[e[r]] = 1;
        for (var o = 0; o < this.length; o++)
            n[this[o]] || (n[this[o]] = 1,
            t.push(this[o]));
        return t
    }
});

```

**To Reproduce(If applicable)**  
Steps to reproduce the behavior:

1. Give the SDK its own public js file. I have webpack mix working on a source file with `import {ZoomMtg} from "@zoomus/websdk";` etc
2. Load the js file when the component mounts
3. Remove the file when the component unmounts, delete #zmmtg-root
4. Load the js file a second time when the component mounts again.

**Device (please complete the following information):**

- Browser: Chrome, but all of them

---

<div class="post-metadata">

**Author:** ![bitcrush-robin](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@bitcrush-robin](https://devforum.zoom.us/u/bitcrush-robin)\
**Post date:** [November 30, 2021, 3:45pm UTC](https://devforum.zoom.us/t/support-for-spas-error-when-reloading-quick-fix/60875/2 "2021-11-30T15:45:55Z")

</div>

For anyone else hoping to fix this themselves, here’s the regex to use with mix.after() or similar:

```auto
/,Object\.defineProperty\(Array\.prototype,"(.+?)"/g,
 ',Array.prototype.$1||Object.defineProperty(Array.prototype,"$1"',

```

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [December 3, 2021, 8:22pm UTC](https://devforum.zoom.us/t/support-for-spas-error-when-reloading-quick-fix/60875/3 "2021-12-03T20:22:40Z")

</div>

Hey @bitcrush-robin,

Thank you for reaching out to the Zoom Developer Forum and for sharing your workaround!

I think that functionality to defer the loading of the SDK or manually unload it would definitely be valuable. Would you be able to create a feature request in our #feature-requests category and send the link to me? I’ll send that to our engineering team to make sure it’s prioritized.

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![bitcrush-robin](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@bitcrush-robin](https://devforum.zoom.us/u/bitcrush-robin)\
**Post date:** [December 8, 2021, 5:09pm UTC](https://devforum.zoom.us/t/support-for-spas-error-when-reloading-quick-fix/60875/4 "2021-12-08T17:09:01Z")

</div>

Hi @MaxM, thanks for the reply.

I’ve posted here now: [Web SDK Support for deferred load and unloading, for SPA sites](https://devforum.zoom.us/t/web-sdk-support-for-deferred-load-and-unloading-for-spa-sites/61219)

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [December 11, 2021, 12:50am UTC](https://devforum.zoom.us/t/support-for-spas-error-when-reloading-quick-fix/60875/5 "2021-12-11T00:50:52Z")

</div>

Hi. @bitcrush-robin,

Thank you for the update! Please be assured we will share this your feedback with our engineer team. In the meantime, please be sure to subscribe to our [blog](https://blog.zoom.us/), and [change log](https://marketplace.zoom.us/docs/changelog) for the latest news, updates, and fixes.

Best,  
Donte

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [January 10, 2022, 10:51am UTC](https://devforum.zoom.us/t/support-for-spas-error-when-reloading-quick-fix/60875/6 "2022-01-10T10:51:19Z")

</div>

Closed on January 10, 2022, 10:51am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
