CreateElement() and Clear() not defined on page load even though it is called in function setup()


I’m currently working on a project (a chrome extension) that loads the canvas onto any site so I can draw on it. However, at random times, I would get errors saying that CreateElement() or Clear() is not defined.

My hypothesis is that p5.js hasn’t loaded yet. But this is counterintuitive since I called it in the setup function which only runs after p5.js has loaded. Please HELP.

Thank you!

Hi @bill.le,

Welcome to the forum! :wink:

Could you share a minimal working example so we can actually test your code and see where the error is?