Hello, I am trying to import Collide2D by
@bmoren into my p5js project. I added the rawgithubcontent link to the minified library in my index.html, but it didn’t import properly. How do I properly import it?
Here is my current index.html:
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="utf-8" />
And here’s mine:
<script defer src=https://cdn.JsDelivr.net/npm/p5></script>
<script defer src=https://cdn.JsDelivr.net/gh/bmoren/p5.collide2D/p5.collide2d.min.js></script>
<script defer src=sketch.js></script>
And an online running sketch too:
this is likely because the raw version that github sends is encoded as plain text and is subject to MIME type sniffing. basically, we need to see this as a js file instead of a text file when it hits the browser.
more info here:
The X-Content-Type-Options response HTTP header is a marker used by the server to indicate that the MIME types advertised in the Content-Type headers should not be changed and be followed. This allows to opt-out of MIME type sniffing, or, in other...
example from the JS console:
try using a CDN service like GoToLoop suggested, or download the file and include it in your sketch locally!
Thanks for the link, helps a lot!
Ooh, okay, that makes sense. I looked up how to import a library and saw someone use a rawgithubcontent link before so I figured it would work for me. Thanks for explaining it!