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

**URL:** <https://discourse.processing.org/t/createelement-and-clear-not-defined-on-page-load-even-though-it-is-called-in-function-setup/37733>\
**Category:** Coding Questions\
**Created:** [June 27, 2022, 2:53pm UTC](https://discourse.processing.org/t/createelement-and-clear-not-defined-on-page-load-even-though-it-is-called-in-function-setup/37733 "2022-06-27T14:53:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bill.le](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@bill.le](https://discourse.processing.org/u/bill.le)\
**Post date:** [June 27, 2022, 2:53pm UTC](https://discourse.processing.org/t/createelement-and-clear-not-defined-on-page-load-even-though-it-is-called-in-function-setup/37733/1 "2022-06-27T14:53:17Z")

</div>

Hi!

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!

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [June 28, 2022, 4:30pm UTC](https://discourse.processing.org/t/createelement-and-clear-not-defined-on-page-load-even-though-it-is-called-in-function-setup/37733/2 "2022-06-28T16:30:54Z")

</div>

Hi @bill.le,

Welcome to the forum! 😉

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