# Library import won´t work

**URL:** https://discourse.processing.org/t/library-import-won-t-work/27364
**Category:** Libraries
**Created:** [January 25, 2021, 3:58pm UTC](https://discourse.processing.org/t/library-import-won-t-work/27364 "2021-01-25T15:58:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![myCatIsAwesome](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@myCatIsAwesome](https://discourse.processing.org/u/myCatIsAwesome)
#### Post date: [January 25, 2021, 3:58pm UTC](https://discourse.processing.org/t/library-import-won-t-work/27364/1 "2021-01-25T15:58:08Z")

</div>

Hello I am pretty new to coding and very new to processing/p5.  
I have the simple problem that if I want to include a library in my p5 project it just won´t work.  
In the web editor I made it work though by simply including the “necessary line of code” in the html index file. But when ever I do this in processing with p5 mode enabled it shuts down completely.  
Just to know if I get this right:  
In p5 (and maybe javascript in general i dont know) you include libraries ONLY by including the line in the html file… and then thats pretty much it?  
Or is there more to it? Could maybe somebody send me a simple edited html index file that only includes the p5 sound library for example?  
Thanks!

---

<div class="post-metadata">

### Author: ![Sierra\_Alpha\_Romeo.P](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sierra_alpha_romeo.p/32/11571_2.png) [@Sierra\_Alpha\_Romeo.P](https://discourse.processing.org/u/Sierra_Alpha_Romeo.P)
#### Post date: [January 25, 2021, 4:37pm UTC](https://discourse.processing.org/t/library-import-won-t-work/27364/2 "2021-01-25T16:37:47Z")

</div>

> [@myCatIsAwesome](#):
>
> In p5 (and maybe javascript in general i dont know) you include libraries ONLY by including the line in the html file…

You can add JavaScript code in an HTML document by employing the dedicated HTML tag `<script>` that wraps around JavaScript code.  
The `<script>` tag can be placed in the `<head>` section of your HTML, in the `<body>` section, or after the `</body>` close tag, depending on when you want the JavaScript to load.  
Generally, any external libraries to be included are added in the `<head>` section of the HTML file. This is where you can add the p5.js library.  
Your p5.js sketch can go in the `<body>` section as it isn’t essential to load a visual sketch before all the other elements of a webpage are loaded.

> [@myCatIsAwesome](#):
>
> and then thats pretty much it?

Yeah. You just need to add the `<script>` tag in the `<head>` section inorder to include that library. Basically the index.html file gathers all the relevant javascript/css/other files at one place. So you can only add javascript libraries/files only in the html file.

> [@myCatIsAwesome](#):
>
> Could maybe somebody send me a simple edited html index file that only includes the p5 sound library for example?

```auto
<!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.2.0/p5.min.js" integrity="sha512-b/htz6gIyFi3dwSoZ0Uv3cuv3Ony7EeKkacgrcVg8CMzu90n777qveu0PBcbZUA7TzyENGtU+qZRuFAkfqgyoQ==" crossorigin="anonymous"> 
    </script>
</head>
<body>
<script src="location of the p5.js sketch file"></script>
</body>
</html>

```

To include any p5.js related library, go to this link

> **[cdnjs - The #1 free and open source CDN built to make life easier for developers](https://cdnjs.com/libraries/p5.js)**
>
> Simple. Fast. Reliable. Content delivery at its finest. cdnjs is a free and open-source CDN service trusted by over 12.5% of all websites, serving over 200 billion requests each month, powered by Cloudflare. We make it faster and easier to load...

Click on the \</\> button which will automatically copy the line which you can paste into the `<head>` section of the html file.  
In the `<script>` tag, there is a `src` attribute where you can add the link to the library(either the CDN or local link)

This has more to do with basic html/javascript knowledge than the p5.js library. Read more about basic html tags on w3schools.

---

<div class="post-metadata">

### Author: ![myCatIsAwesome](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@myCatIsAwesome](https://discourse.processing.org/u/myCatIsAwesome)
#### Post date: [January 25, 2021, 7:47pm UTC](https://discourse.processing.org/t/library-import-won-t-work/27364/3 "2021-01-25T19:47:17Z")

</div>

> [@Sierra\_Alpha\_Romeo.P](#):
>
> This has more to do with basic html/javascript knowledge than the p5.js library

Yes I had that feeling myself. Sometimes when stuff doesnt work out at all and I dont really get a lot of things at the same time its hard for me to ask the right questions!  
This answer was just perfect. Will definitely check out html as well as a bunch of front end related stuff which really don´t know anything about. Thank you very much!
