@dakito What do you mean with:
In addition, what do you mean in your statement: It works perfectly fine if running a local server. How are you running this local server?
Just to make sure we are on the same page, a local server simulates a server in your computer and I am assuming that is what you are referring to. You do not need to have a local server to run p5.js code. To run p5js, at a minimum, you will need your html and js code plus additional resources like images. In the simple case, all files (html,js,jpg,png,etc) could reside in the same folder. Then you can move this folder anywhere in your computer (or share it) and your html should work when loaded in any browser (chrome, firefox, safari, etc).
Kf