# Async in p5.js editor

**URL:** <https://discourse.processing.org/t/async-in-p5-js-editor/3772>\
**Category:** p5.js\
**Created:** [September 23, 2018, 5:23pm UTC](https://discourse.processing.org/t/async-in-p5-js-editor/3772 "2018-09-23T17:23:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lillbre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lillbre/32/18325_2.png) [@Lillbre](https://discourse.processing.org/u/Lillbre)\
**Post date:** [September 23, 2018, 5:23pm UTC](https://discourse.processing.org/t/async-in-p5-js-editor/3772/1 "2018-09-23T17:23:04Z")

</div>

I’m “coding along” with The Coding Train 7.11: TensorFlow.js but when I want to use async/await in the editor I get an error. Is it not possible to use async in that editor or is there something I have to add for making it work?

---

<div class="post-metadata">

**Author:** ![julian2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/julian2/32/1551_2.png) [@julian2](https://discourse.processing.org/u/julian2)\
**Post date:** [September 23, 2018, 8:28pm UTC](https://discourse.processing.org/t/async-in-p5-js-editor/3772/2 "2018-09-23T20:28:22Z")

</div>

[https://editor.p5js.org/julian2/sketches/Hk2qE\_HY7](https://editor.p5js.org/julian2/sketches/Hk2qE_HY7)

You’re allowed to write code with async/await (your browser should definitively support it), and it works as it should (as promised). But I believe it’s just the editor here that _displays_ the async/await syntax as an error (even though it’s valid syntax)! I think it comes down to p5js only supporting a certain version of ecmascript? (citation needed!), and since async / await is pretty new (somewhere between es2016 and es2017? I’m not sure exactly when! 🙊 ) then it hasn’t been added to p5js’ syntax highlighting / static code error checker.

Since we’re running code in the browser / clientside, it should really just be a matter of browser support & async/await has been supported by all major browsers for a while! 😃

[https://caniuse.com/#feat=async-functions](https://caniuse.com/#feat=async-functions)

---

<div class="post-metadata">

**Author:** ![julian2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/julian2/32/1551_2.png) [@julian2](https://discourse.processing.org/u/julian2)\
**Post date:** [September 23, 2018, 9:28pm UTC](https://discourse.processing.org/t/async-in-p5-js-editor/3772/3 "2018-09-23T21:28:00Z")

</div>

digging into the code for the p5js web editor Seems it uses jshint for doing its static code analysis, and currently there’s an issue already open for supporting async/await here! 😄, so I gave that issue a thumbs up at least! [https://github.com/jshint/jshint/issues/2604](https://github.com/jshint/jshint/issues/2604)

also just to note this down somewhere (not really important to this issue / thread I guess), it seems that it uses codemirror [https://codemirror.net/](https://codemirror.net/), and there seems to be a lot of unused potential there (stuff I would want enabled!) in the addons section for it [https://codemirror.net/doc/manual.html#addons](https://codemirror.net/doc/manual.html#addons). eg. the match-highlighter.js! (highlighting the selected variable other places in code), and also tern/tern.js for multiple occurrence matching & refactoring. But I guess at some point it would just make more sense to switch to your IDE of choice, where you have all the features you find comfortable! 🙂

---

<div class="post-metadata">

**Author:** ![Lillbre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lillbre/32/18325_2.png) [@Lillbre](https://discourse.processing.org/u/Lillbre)\
**Post date:** [September 24, 2018, 3:59pm UTC](https://discourse.processing.org/t/async-in-p5-js-editor/3772/4 "2018-09-24T15:59:56Z")

</div>

> [@julian2](#):
>
> [p5.js Web Editor](https://editor.p5js.org/julian2/sketches/Hk2qE_HY7)

Thanks julian2!  
When I watch your code it looks all right but if I rewrite the word ascync on line 13 it looks as in the uploaded picture.

 ![async](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/02886b4243dff5623e1c6a343574e269519d9243.png)

---

<div class="post-metadata">

**Author:** ![julian2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/julian2/32/1551_2.png) [@julian2](https://discourse.processing.org/u/julian2)\
**Post date:** [September 24, 2018, 9:43pm UTC](https://discourse.processing.org/t/async-in-p5-js-editor/3772/5 "2018-09-24T21:43:06Z")

</div>

yeah, it should only be a false positive error :), the code still runs if you press play right? (so don’t worry about the async / await errors, the best I think we can do for now is to ignore them in the web editor until it’s fixed 🙂 )
