Can you mix sequential and parallel await in JavaScript?
Yes. First sequential await for dependent operations, then Promise.all for independent ones: const user = await fetchUser(); const [posts, friends] = await Promise.all([fetchPosts(user.id), fetchFriends(user.id)]);
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Sequential vs Parallel await in JavaScript
Sequential await waits for each operation to complete before starting the next (total time is the sum). Parallel await with Promise.all starts all operations at once (total time is the longest operation). Use parallel for independent operations.
When operations depend on each other. For example, const user = await fetchUser(id); const posts = await fetchPosts(user.id);. fetchPosts needs user.id, so you must wait for fetchUser first.
Use Promise.all: const [a, b, c] = await Promise.all([fetchA(), fetchB(), fetchC()]). Start all promises at once, then await all. This is much faster than sequential await for independent operations.
Still have questions?
Browse all our FAQs or reach out to our support team
