# How to use export & import in p5.js

**URL:** https://discourse.processing.org/t/how-to-use-export-import-in-p5-js/31724
**Category:** Coding Questions
**Created:** [August 14, 2021, 9:14am UTC](https://discourse.processing.org/t/how-to-use-export-import-in-p5-js/31724 "2021-08-14T09:14:06Z")
**Posts on this page:** 1
**Showing post:** 8

<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: [August 15, 2021, 6:42pm UTC](https://discourse.processing.org/t/how-to-use-export-import-in-p5-js/31724/8 "2021-08-15T18:42:28Z")

</div>

> [@micuat](#):
>
> Also `setup` / `draw` has to be defined as a member of `window` to be picked up by p5.js.

That’s right! A JS module got 2 global contexts: A private 1 and a shared 1.

Explicitly appending to _window_ or _globalThis_ assures those properties can be accessed by both vanilla & module scripts which are sharing the same global context.

---

_[View the full topic](https://discourse.processing.org/t/how-to-use-export-import-in-p5-js/31724)._
