When I use bg = loadImage("data/Myimage.jpg"); or bg = loadImage('data/Myimage.jpg'); or bg = loadImage("Myimage.jpg"); or bg = loadImage('Myimage.jpg'); it says " file:///C: ..... from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access."
I have tried using bg = createImg('Myimage.jpg'), (createImage doesnt work ...) and it works, but then I can't use background(bg); , it says "Uncaught Error: [object Arguments]is not a valid color representation.".
I also tried background(bg,10); and background(bg,100); it doesnt give any error on the console, but it doesnt show any image.
is the image file within a folder called date within your project folder? the page specified in loadImage() should be relative to your html file.
Are you working on a server? CORS is usually blocked on local files.
Here is a place in the wiki on setting up a local server: https://github.com/processing/p5.js/wiki/Local-server
Most helpful comment
Here is a place in the wiki on setting up a local server: https://github.com/processing/p5.js/wiki/Local-server