# P5.js Web Editor problem exporting a function

**URL:** <https://discourse.processing.org/t/p5-js-web-editor-problem-exporting-a-function/45420>\
**Category:** Beginners\
**Created:** [December 2, 2024, 7:41pm UTC](https://discourse.processing.org/t/p5-js-web-editor-problem-exporting-a-function/45420 "2024-12-02T19:41:08Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [December 3, 2024, 1:36pm UTC](https://discourse.processing.org/t/p5-js-web-editor-problem-exporting-a-function/45420/4 "2024-12-03T13:36:04Z")

</div>

> [@edufissure](#):
>
> I think `import` / `export` don’t work in p5.js…

Those 2 keywords are JS features, and p5.js, which is a frontend library, can’t change that:

> [@Import class other file syntax error](https://discourse.processing.org/t/import-class-other-file-syntax-error/45358/12):
>
> Your “Calculadora.zip” file had to many things in it. I’ve removed most of it and edited the rest. Also, I’ve created a GitHub repo for it here: You can also check it running online on this link:

> <https://github.com/GoToLoop/P5-JS-ECMA-Module-Demo/blob/main/src/sketch.mjs>

> <https://github.com/GoToLoop/P5-JS-ECMA-Module-Demo/blob/main/src/classes/Animal.mjs>

> [@edufissure](#):
>
> … don’t know if it’s a bug, or is not implemented yet,

As I have already mentioned to you on your previous forum thread:

> [@Import class other file syntax error](https://discourse.processing.org/t/import-class-other-file-syntax-error/45358/9):
>
> p5.js itself is a regular .js library file, not a module 1.
> 
> Indeed they’ve never yet cared about using ECMA module (.mjs) files in the browser!
> 
> But weirdly, they do care about Node.JS’ Common module (.cjs) files, even though p5.js isn’t a backend library, but a frontend 1!

B/c they don’t even acknowledge ECMA Script Modules (ESM / “.mjs”) exist anywhere on their docs, it’s no wonder their “p5.js Web Editor” doesn’t seem to be compatible w/ ESM either!

Pretty much any other JS code hosting/editor solution available should work!

For example, you can try out:

- [OpenProcessing.org](http://OpenProcessing.org)
- [Glitch.com](http://Glitch.com)
- [GitHub.com](http://GitHub.com)

And many others to host JS code + p5.js library!

---

_[View the full topic](https://discourse.processing.org/t/p5-js-web-editor-problem-exporting-a-function/45420)._
