# Linking classes between files outside of p5js web editor

**URL:** https://discourse.processing.org/t/linking-classes-between-files-outside-of-p5js-web-editor/42048
**Category:** Beginners
**Created:** [May 22, 2023, 5:47am UTC](https://discourse.processing.org/t/linking-classes-between-files-outside-of-p5js-web-editor/42048 "2023-05-22T05:47:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![hifilo](https://avatars.discourse-cdn.com/v4/letter/h/da6949/32.png) [@hifilo](https://discourse.processing.org/u/hifilo)
#### Post date: [May 22, 2023, 5:47am UTC](https://discourse.processing.org/t/linking-classes-between-files-outside-of-p5js-web-editor/42048/1 "2023-05-22T05:47:45Z")

</div>

Hello,

in the p5js web editor I noticed you can separate classes with files, by linking the class.js inside index.html.

Is this specific to the p5js web editor or can I link classes the same way in another IDE?

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [May 22, 2023, 4:00pm UTC](https://discourse.processing.org/t/linking-classes-between-files-outside-of-p5js-web-editor/42048/2 "2023-05-22T16:00:19Z")

</div>

Hi @hifilo,

Don’t see why not. Usually you have also an index.html in your vscode project. Just add your classes by adding additional script tags. Keep in mind that you eventually have to respect the order of your classes. Means if you have derived classes you need to add the parent first

Cheers  
— mnse

---

<div class="post-metadata">

### Author: ![hifilo](https://avatars.discourse-cdn.com/v4/letter/h/da6949/32.png) [@hifilo](https://discourse.processing.org/u/hifilo)
#### Post date: [May 22, 2023, 5:02pm UTC](https://discourse.processing.org/t/linking-classes-between-files-outside-of-p5js-web-editor/42048/3 "2023-05-22T17:02:08Z")

</div>

Thank you, I haven’t tried yet but I will.

Simply placing a script tag makes everything in a script available for other files? And this applies to vanilla JS as well?

I ask because I know import/export is how you connect different methods/functions/classes between files, but by placing the .js file directly in the html tag, this makes the import/export unnecessary.

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [May 22, 2023, 6:13pm UTC](https://discourse.processing.org/t/linking-classes-between-files-outside-of-p5js-web-editor/42048/4 "2023-05-22T18:13:01Z")

</div>

> [@hifilo](#):
>
> And this applies to vanilla JS as well?

Yes! But you should encapsulate the several functionalities to not accidentally override stuff from a global context.

Cheers  
— mnse

---

<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: [May 22, 2023, 6:21pm UTC](https://discourse.processing.org/t/linking-classes-between-files-outside-of-p5js-web-editor/42048/5 "2023-05-22T18:21:57Z")

</div>

> [@Shared library for simple functions](https://discourse.processing.org/t/shared-library-for-simple-functions/18374/4):
>
> The “index.html” file can be written as short as this: cowboy_hat_face \<script src=https://cdn.JsDelivr.net/npm/p5\>\</script\> \<script src=https://po4599.GitHub.io/javascript/grid.js\>\</script\> \<script src=sketch.js\>\</script\> Take another look at the short “index.html” above and you won’t spot any quotes or anything like it! stuck_out_tongue How about instead coding your “grid.js” library in such a way that it seamlessly injects itself into the p5js library as part of its API? …
