Is it safe to use async-await in Javascript instead of
generators-promises now, knowing that the syntax has not made yet and
will be coming with the release of ES8?
What browsers can I count on it being available, and how common are the browsers where this syntax is not available? By Safe I mean without some transpilers like babel?
There are two places I check whenever I have questions such as this:
The Can I Use website: http://caniuse.com/#search=await
And Node Green: http://node.green/#async-functions
Typically an answer is encouraged to include the relevant information to avoid link rot. But ironically this answer has exactly the opposite problem: this answer will rot (the information below will become invalid) long before the links above. So always check caniuse and node.green first:
From caniuse.com as of February 2017:
- IE: NOT SUPPORTED (most used version = 11)
- Edge*: From version 15 (most used version = 14)
- Firefox: From version 52 (most used version = 50)
- Chrome: From version 55 (most used version = 55)
- Safari: From version 10.1 (most used version = 10)
- Opera: From version 42 (most used version = 42)
- iOS Safari: From version 10.3 (most used version = 10.2)
- Opera Mini*: NOT SUPPORTED
- Android Browser*: NOT SUPPORTED (most used version = 4.4)
- Chrome for Android: From version 55 (most used version = 55)
From node.green as of February 2017
- Node.js: From version 8.0.0
So depending on what you think is acceptable it is either safe or not safe. Note that most mobile devices don't support it and as of February 2017 most node.js installations are version 6 with some starting to move to version 7 (some libraries seem to have problems with node 7) and neither versions support async/await. Node 8 is not released yet and is only available as nightly builds.