Multiple instances of the same p5js sketch?

B/c it’s a global mode sketch, you can have at most 1 per page.

As a workaround, you can place other global mode instances of it inside their own <iframe> tag:

Or simply convert it to instance mode, so you can have multiples of it on the same page context:

Here’s an example of 4 instances of the same sketch running on the same page:

Go to the link below for its full source code:

Just click the button “View Source”.

2 Likes