Performance: Async/await syntax
MEDIUM IMPACT
Async/await affects how JavaScript handles asynchronous operations, impacting input responsiveness and event loop efficiency.
async function fetchData() { const response = await fetch('https://api.example.com/data'); const json = await response.json(); // process json // more code }
function fetchData() {
const data = fetch('https://api.example.com/data').then(response => response.json()).then(json => {
// process json
});
// more code
}| Pattern | Event Loop Blocking | Code Readability | Latency Impact | Verdict |
|---|---|---|---|---|
| Chained .then() Promises | No blocking | Harder to read | Moderate | [!] OK |
| Async/await Sequential | No blocking | Easy to read | High latency | [X] Bad |
| Async/await Parallel Promises | No blocking | Easy to read | Low latency | [OK] Good |