# Importing classes from an external GitHub repo

**URL:** <https://discourse.processing.org/t/importing-classes-from-an-external-github-repo/42394>\
**Category:** Libraries\
**Created:** [July 10, 2023, 8:42am UTC](https://discourse.processing.org/t/importing-classes-from-an-external-github-repo/42394 "2023-07-10T08:42:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Broccaaa](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@Broccaaa](https://discourse.processing.org/u/Broccaaa)\
**Post date:** [July 10, 2023, 8:42am UTC](https://discourse.processing.org/t/importing-classes-from-an-external-github-repo/42394/1 "2023-07-10T08:42:50Z")

</div>

I want to use some JavaScript tools located on the following github repo: [GitHub - mfogel/polygon-clipping: Apply boolean polygon clipping operations (union, intersection, difference, xor) to your Polygons & MultiPolygons.](https://github.com/mfogel/polygon-clipping)

I’ve tried installing with npm and then pointing a tag to the library but I must be doing something wrong?

Please help!

I suspect this is a very simple process to follow but I just can’t get it to work.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [July 10, 2023, 8:45pm UTC](https://discourse.processing.org/t/importing-classes-from-an-external-github-repo/42394/2 "2023-07-10T20:45:16Z")

</div>

Just copy the code that you need to a separate tab

---

<div class="post-metadata">

**Author:** ![Broccaaa](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@Broccaaa](https://discourse.processing.org/u/Broccaaa)\
**Post date:** [July 11, 2023, 7:13am UTC](https://discourse.processing.org/t/importing-classes-from-an-external-github-repo/42394/3 "2023-07-11T07:13:08Z")

</div>

So copy all code from the ~15 source module folders?

Isn’t there a better way to use external code that is more robust managing dependencies and code versions?

Perhaps some equivalent to require() or import that works with p5.js??

---

<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:** [July 11, 2023, 2:10pm UTC](https://discourse.processing.org/t/importing-classes-from-an-external-github-repo/42394/4 "2023-07-11T14:10:20Z")

</div>

Hi @Broccaaa,

just put this in your html and use it …

```auto
<script src="https://cdn.jsdelivr.net/npm/polygon-clipping@0.15.3/dist/polygon-clipping.umd.min.js">/script>

```

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![Broccaaa](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@Broccaaa](https://discourse.processing.org/u/Broccaaa)\
**Post date:** [July 11, 2023, 2:22pm UTC](https://discourse.processing.org/t/importing-classes-from-an-external-github-repo/42394/5 "2023-07-11T14:22:56Z")

</div>

Yes thank you!

It was this bundled/minimized script I needed.

---

<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:** [July 11, 2023, 3:01pm UTC](https://discourse.processing.org/t/importing-classes-from-an-external-github-repo/42394/6 "2023-07-11T15:01:16Z")

</div>

File “package.json” has a “browser” entry w/ “dist/polygon-clipping.umd.js”:

> <https://github.com/mfogel/polygon-clipping/blob/main/package.json>

That library is primarily for NodeJS. That’s why we have to look for the “browser” version file.

---

<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:** [July 11, 2023, 3:10pm UTC](https://discourse.processing.org/t/importing-classes-from-an-external-github-repo/42394/7 "2023-07-11T15:10:01Z")

</div>

BtW, here’s a minimalist “index.html” to remotely load both “p5\*js” & “polygon-clipping”, plus “sketch.js”:

```auto
<script defer src=//cdn.JsDelivr.net/npm/p5></script>
<script defer src=//cdn.JsDelivr.net/npm/polygon-clipping></script>
<script defer src=sketch.js></script>

```
