# P5 loadSound not defined

**URL:** <https://discourse.processing.org/t/p5-loadsound-not-defined/2291>\
**Category:** p5.js\
**Created:** [August 2, 2018, 1:11am UTC](https://discourse.processing.org/t/p5-loadsound-not-defined/2291 "2018-08-02T01:11:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NycGio](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nycgio/32/978_2.png) [@NycGio](https://discourse.processing.org/u/NycGio)\
**Post date:** [August 2, 2018, 1:11am UTC](https://discourse.processing.org/t/p5-loadsound-not-defined/2291/1 "2018-08-02T01:11:21Z")

</div>

I keep getting an error saying loadSound is not defined here is my code if anyone can help me out.

index.html

```auto
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Server</title>

  <scirpt src="./p5/addons/p5.sound.js"></scirpt>
  <script src="./p5/p5.js"></script>
  <scirpt src="./p5/addons/p5.dom.min.js"></scirpt>
  <script src="./sketch.js"></script>

  <style>
    body {
      overflow: hidden;
      margin: 0px;
      padding: 0px;
    }
  </style>
</head>

<body>

</body>

</html>

```

the js code

```auto
var song, analyzer, fft, peakDetect, peaks;
var timestamp = new Date().getTime();
var canvas;

function preload() {
  song = loadSound("song.mp3");
  song.play();
}

function draw() {
  background(51);
}

function setup() {
  canvas = createCanvas(windowWidth, windowHeight);
}

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}

```

any idea why i keep getting this error all libraries are up to date

---

<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:** [August 2, 2018, 1:50am UTC](https://discourse.processing.org/t/p5-loadsound-not-defined/2291/2 "2018-08-02T01:50:12Z")

</div>

This “index.html” file below should work for your “sketch.js” file: 👷‍♂️

## “index.html”:

```auto
<!DOCTYPE html>

<meta charset=utf-8>
<meta name=viewport content=width=device-width,initial-scale=1>

<script defer src=https://cdn.JsDelivr.net/npm/p5></script>
<script defer src=https://cdn.JsDelivr.net/npm/p5/lib/addons/p5.dom.min.js></script>
<script defer src=https://cdn.JsDelivr.net/npm/p5/lib/addons/p5.sound.min.js></script>

<script defer src=sketch.js></script>

```

---

<div class="post-metadata">

**Author:** ![NycGio](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nycgio/32/978_2.png) [@NycGio](https://discourse.processing.org/u/NycGio)\
**Post date:** [August 2, 2018, 2:48am UTC](https://discourse.processing.org/t/p5-loadsound-not-defined/2291/3 "2018-08-02T02:48:36Z")

</div>

it worked thanks! is there a reason why importing localy won’t work?

---

<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:** [August 2, 2018, 9:40am UTC](https://discourse.processing.org/t/p5-loadsound-not-defined/2291/4 "2018-08-02T09:40:42Z")

</div>

> [@NycGio](#):
>
> Is there a reason why importing locally won’t work?

Nope, not at all! 🕶  
But after a 2nd glance on your own “index.html”, I can see those “.js” files are loaded outta order! 😰

Always keep in mind the library file “p5.js” is the main 1. 🗓  
And the other “p5.some\_addon\_lib.js” files depend on it. 🙇‍♂️
