P5 value changed bug

Every time i used p5.js, it says “You just changed the value of “something”, which was a p5 function. This could cause problems later if you’re not careful.”. It still works, but when i created a canvas, it showed 2 and everything I did it did it twice. Anyone has got a fix to this? If so, thanks!

You changed the value of… what? Of something? Do you have a variable named something? Could you rename it? It’s basically impossible to help you without seeing the exact error and a snippet of code that demonstrates the error…

oh the something was just a replacement for all the errors.
Here’s the actual error.

Hi @Galaxy, can you share the code for your index.html with us? I think what you’re seeing can happen if you include p5 multiple times—let’s see if that’s happening. :slight_smile:

1 Like


Here is my html code.

Well, you have both p5.js and p5.min.js included, don’t you?

I’d try removing the 4th “<script>...</script>” line… See if that helps…

1 Like

But i thought i was supposed to use both of them? A few weeks ago there wasn’t any problems, this just suddenly happen. I’ll try it and see.

Thanks, it worked. So I am just supposed to use the p5.js file instead of using both p5.js and p5.min.js files next time? It used to work

One or the other, but not both. I’m not sure what the difference is myself. One is “compressed” and the other isn’t, but that’s not super informative.

1 Like

Alright then. Thanks for helping me.

1 Like

Great! Glad you worked this out. Also, FYI we have a bug open in the project to make it easier for users to figure out if this happens in the future: https://github.com/processing/p5.js/issues/2681

2 Likes

Yes, use either one or the other.

I believe that using both causes a pile of warnings because the second library loading redefines all of the exact same methods in the first one – you are overwriting the first library piece by piece (with an almost identical minified or maxified copy), and getting a warning every step of the way.

Oooh, thanks for the information.

I’ll be sure to use it the next time I encounter a bug.

Chiming in for future reference and to help make this answer fully complete! The difference between a regular js file and a min js file is that all of the white space (returns, spaces, etc.) has been removed in the min version. It’s not exactly compressed per se, but the white space is unnecessary data (as far as the computer/browser is concerned), and is stripped out. The regular p5.js file has all of this formatting and white space and is the human readable version.

currently (v0.6.1)
the p5.js file is 2.8mb
the p5.min.js file is 399kb
So using the min is substantially smaller which would result in faster downloads and less bandwidth usage.

Generally speaking it’s best to go with the min for speed and efficiency, but you might want the p5.js file to look at what is actually happening under the hood in a human readable format for debugging, learning, or adding on.

It’s a good idea to open each of these in your text editor and have a look! functionally they do the same thing, but they look very different.

4 Likes