Reference is Null, p5 load order?

This could be relevant: [SOLVED] Accessing html elements defined into .html file?

Make sure you are including p5.dom.js as it is not clear in the code you provided.

Kf