General question on p5.js

Hi!
I wanna create my one website and therefore want to learn programming with p5.js. I have e question, however. The p5.js library files have together have a size of eight MB. Does this mean, these 8 MB have to downloaded from the server to the user when the website is called up by the user?

Thanks for any answers!

1 Like

Hello, @user101, and welcome to the Processing Community!

See the page p5.js: Get Started.

Note this on the page:

If you look in index.html, you’ll notice that it links to the file p5.js. If you would like to use the minified version (compressed for faster page loading), change the link to p5.min.js.

<script src="../p5.min.js"></script>

That minified file is less than a megabyte in size. Adapt the link to the location from which you serve the file.

EDIT (October 23, 2021):

Depending upon the particulars of a given sketch that you host, the user might only need to be served the following:

  • Your .html file
  • Your .js sketch file
  • Your .css file
  • p5.min.js

In total, that might be less than a megabyte.

1 Like

Hi @user101,

Welcome to the forum! :wink:

About the average page weight of webpages today, here’s an interesting blog post about it:

On average it’s about 7MB and yes it needs to be transferred from the server to the client with HTTP. I don’t know if this number includes compression but most of the time it’s compressed by the server using gzip or Broti which reduces bandwidth usage :+1:

It doesn’t need to be from your own server. :wink:
You can grab libraries from a CDN server instead, like the example tag below: :shushing_face:

<script defer src=https://cdn.JsDelivr.net/npm/p5></script>

cdn.JsDelivr.net/npm/p5

1 Like

Yes it is quite a big library for what it is but that’s the trade off with usability.

There are smaller alternatives, which may be interesting for you

1 Like