Again if you are using WEBGL with p5.js it’s already the case. The limitation is due to your graphics card and the number of objects you want to draw. What I wanted to say is if p5.js is not giving enough performance, you might want to look into low level optimization tricks with webgl and rendering on different buffers…
You might also want to look into Godot game engine which open source and well suited for 2d and web export!