Help with integrating a Javascript p5 file into HTML

Just started trying to learn HTML, and I’m having trouble using a Javascript file within it. I want to use the p5.js Javascript library and I have created a canvas within a file called sketch.js. Why does only my H1 show up when I run the HTML? Sorry for being a big noob, here’s the HTML code:

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

<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Web Page</title>
 <script src="/sketch.js"></script>
</head>

<body>
 <h1>Hello World!</h1>
</body>

</html>
1 Like

B/c you aren’t loading the p5.js library within your HTML file, just your “sketch.js” file: :warning:

1 Like

Of course! Thanks so much :grinning:

Still not 100% how this works as the src I’m using points to a page instead of somewhere in my files where I have saved p5.js, but I used this line in the head tag:

  <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.js"></script>

and it’s finally displaying my code, thanks!

1 Like