Is it safe to use async/await now? [closed]
Asked Answered
G

1

60

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?

Ginn answered 12/2, 2017 at 1:9 Comment(4)
What does "safe" mean? Safe for whom, where, against what possibility?Weatherspoon
The syntax is not going to change, but you'll want to use transpilers for a long while. Does "safe" mean with or without transpilation?Hurds
without some transpilers - what is the environment you want to be safe in? browsers? definitely not, almost never until the world decides that internet explorer is finally dead - node, doesn't support it (yet)Fakir
To put things into perspective, async/await has not been officially released yet.Towroy
N
85

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 April 2019 :

  • IE *: NOT SUPPORTED (most used version = 11)
  • Edge: From version 15 (most used version = 17)
  • Firefox: From version 52 (most used version = 65)
  • Chrome: From version 55 (most used version = 72)
  • Safari: From version 10.1 (most used version = 12)
  • Opera: From version 42 (most used version = 58)
  • iOS Safari: From version 10.3 (most used version = 12.1)
  • Opera Mini *: NOT SUPPORTED
  • Android Browser *: From 5 (most used version = 4.4)
  • Chrome for Android: From version 55 (most used version = 71)

From node.green as of April 2019

  • Node.js: From version 8.0.0

So depending on what you think is acceptable it is either safe or not safe. Note the following:

  • This question was originally asked on 2017, and we have come a long way so async/await is much more safe to use now.
  • By 2019, most mobile devices already support async/await.
  • Node 8 is released on May 2017 so it should be safe to use async/await on Node.js unless your Node.js servers are very outdated.
Nannana answered 12/2, 2017 at 3:28 Comment(2)
Added most used version for caniuse data. It seems that the most used browser in the world is Chrome for Android at around 25% global usageNannana
According to the release notes, Safari 10.1 added support for ECMAScript 2016 and ECMAScript 2017 in Safari for macOS and iOS, including support for async and await.Maltz

© 2022 - 2024 — McMap. All rights reserved.