Google News
logo
p5.js - Interview Questions
How to Include the p5.js Library?
The p5.js library must be included using a <script> tag in the <head> section of an HTML document. Only then, the p5.js library can be used in a JavaScript file.

A p5.js library can be any JavaScript code that extends or adds to the p5.js core functionality. There are two categories of libraries. Core libraries (p5.sound) are part of the p5.js distribution, while contributed libraries are developed, owned, and maintained by members of the p5.js community.
 
To include a library in your sketch, link it into your HTML file, after you have linked in p5.js. An example HTML file might look like this :
<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- Include p5.js library -->
    <script src="p5.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
    <meta charset="utf-8" />
  </head>
  <body>
    <script src="p5.sound.js"></script>
    <script src="sketch.js"></script>
  </body>
</html>​
Advertisement