Displaying p5.js sketches on a Wordpress site

Could anyone tell me in an idiot-proof way, how I can display p5.js sketches on a Wordpress site. I’ve worked out how to embed the web editor, but I’d prefer to upload the files to the site. I’d also prefer not to rely on a plugin (the developers seem to stop updating them after a while). I don’t know which files to put where. Could anyone help me out? Thanks

A basic p5.js sketch is just HTML and Javascript (which can be anywhere in an HTML file in a tag). So you should be able to put it anywhere you can put raw HTML. Depending on your WP hosting solution you might be restricted from posting JavaScript which would be problematic. The other important consideration is if you are loading other assets like images, fonts, or sounds. You will need to make sure you are using the correct URL for these based on where they are on your WP site (I believe WP let’s you upload arbitrary files and hosts them at some /wp-uploads/… Url. Additionally if you load assets from other hosts those hosts may need to support CORS headers.

Long story short there is no “fool proof” way.

2 Likes

Thanks. I’ll give it a whirl then and see what happens.