# How to use classes in instance mode?

**URL:** <https://discourse.processing.org/t/how-to-use-classes-in-instance-mode/18807>\
**Category:** Beginners\
**Created:** [March 19, 2020, 5:10pm UTC](https://discourse.processing.org/t/how-to-use-classes-in-instance-mode/18807 "2020-03-19T17:10:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josephcscarpa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephcscarpa/32/8450_2.png) [@josephcscarpa](https://discourse.processing.org/u/josephcscarpa)\
**Post date:** [March 19, 2020, 5:10pm UTC](https://discourse.processing.org/t/how-to-use-classes-in-instance-mode/18807/1 "2020-03-19T17:10:51Z")

</div>

I have two sketches that I would like to run on a single page and the only way this is possible with instance mode. I am just not sure how to incorporate classes used in those sketches in instance mode. Has anyone done this successfully and wouldn’t mind sharing their code? Really any help at all is appreciated.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 19, 2020, 5:48pm UTC](https://discourse.processing.org/t/how-to-use-classes-in-instance-mode/18807/2 "2020-03-19T17:48:18Z")

</div>

> [@josephcscarpa](#):
>
> … and the only way this is possible with instance mode.

We can put extra sketches in their own `<iframe>` tag, regardless if they’re global or instance mode.

> [@josephcscarpa](#):
>
> I am just not sure how to incorporate classes used in those sketches in instance mode.

Some example sketch using both modes + class:

> <https://gist.github.com/GoSubRoutine/60b154e52336f7fee7c5f1fe817ceb22>
>
> There are more than three files. show original

Same sketch but also using a 3rd-party library + `import` & `export`:

- [Glitch :･ﾟ✧](http://Glitch.com/edit/#!/matter-js-bouncing-colorful-balls?path=sketches/global.mjs)

---

<div class="post-metadata">

**Author:** ![josephcscarpa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephcscarpa/32/8450_2.png) [@josephcscarpa](https://discourse.processing.org/u/josephcscarpa)\
**Post date:** [March 23, 2020, 2:00pm UTC](https://discourse.processing.org/t/how-to-use-classes-in-instance-mode/18807/3 "2020-03-23T14:00:51Z")

</div>

Thank you! This is exactly what I needed.
