# \[SOLVED\] Adding createButton() causes an error

**URL:** <https://discourse.processing.org/t/solved-adding-createbutton-causes-an-error/11296>\
**Category:** Beginners\
**Created:** [May 16, 2019, 5:27am UTC](https://discourse.processing.org/t/solved-adding-createbutton-causes-an-error/11296 "2019-05-16T05:27:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![akathewb](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/akathewb/32/3364_2.png) [@akathewb](https://discourse.processing.org/u/akathewb)\
**Post date:** [May 16, 2019, 5:27am UTC](https://discourse.processing.org/t/solved-adding-createbutton-causes-an-error/11296/1 "2019-05-16T05:27:30Z")

</div>

Error:  
**Uncaught ReferenceError: createButton is not defined**

Things I’ve tried to fix:

1. I tried replacing the script tag to the CDN version of p5 8.0 thinking maybe I was not using the latest code base, but this did not work
2. Tried running code on a local server, also did not work got same error
3. Tried… button = createButton(“this is a button”)… got same error.
4. Tried pasting in sample code from the reference documents and this did not work either.

Thanks for any help on this one, code below

```auto
var bgColor;

function setup(){
    createCanvas(400,400);
    createButton("this is a button"); //Adding this gives an error.
    bgColor = color(200);
}

function changeColor(){
    bgColor = color(random(255));
}

function mousePressed(){
    changeColor();
}

function draw(){
    background(bgColor);
    fill(255,0,0);
        
}

```

HTML FILE

```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">
    <script src="p5js/p5.dom.min.js"></script>
    <script src="p5js/p5.min.js"></script>
    <script src="p5js/p5.sound.min.js"></script>
    <!-- <link rel="stylesheet" href="style.css"> -->
    
    <title>Sketch</title>
</head>
<body>
    <h1>Hello World</h1>
    <p>Super duper this is some text on the screen</p>
    <p>Yeah and this is some more text on the screen</p>
    <script src="sketch.js"></script> 
</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![akathewb](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/akathewb/32/3364_2.png) [@akathewb](https://discourse.processing.org/u/akathewb)\
**Post date:** [May 16, 2019, 5:37am UTC](https://discourse.processing.org/t/solved-adding-createbutton-causes-an-error/11296/2 "2019-05-16T05:37:41Z")

</div>

Switching the order of the script tags in the HTML solved this…  
p5 needed to come before the dom…

```auto
<script src="p5js/p5.min.js"></script>
<script src="p5js/p5.dom.min.js"></script>

```
