<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq" -->

---
title: Fixing Top-Level Await in Safari | daily.dev
description: Safari 27&#x27;s WebKit engine now fully complies with the ECMAScript spec for top-level await, fixing longstanding bugs that caused &#x27;accessed before...
canonical: https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Fixing Top-Level Await in Safari | daily.dev
og:description: Safari 27&#x27;s WebKit engine now fully complies with the ECMAScript spec for top-level await, fixing longstanding bugs that caused &#x27;accessed before...
og:url: https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq
og:image: https://api.daily.dev/og/posts/kCSPlB3AQ.png
og:image:alt: Fixing Top-Level Await in Safari
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Fixing Top-Level Await in Safari

**[WebKit](https://daily.dev/sources/webkit)** · 8 min read · 14 upvotes · 3 comments

## Summary

Safari 27's WebKit engine now fully complies with the ECMAScript spec for top-level await, fixing longstanding bugs that caused 'accessed before initialization' errors and incorrect module evaluation ordering. The team rewrote Safari's module loader from scratch in native C++, replacing an outdated implementation based on the abandoned WHATWG Loader proposal. The rewrite was validated using fuzzing, test262, WPT tests, and test cases contributed by Bun engineers, and is available now in Safari Technology Preview 251 and the Safari 27 beta.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://webkit.org/blog/18227/fixing-top-level-await-in-safari>

## Questions this post answers

### Why did top-level await cause 'Cannot access before initialization' errors in Safari?

Safari's old module loader was built on the abandoned WHATWG Loader proposal from before async/await existed in ECMAScript, so it resolved import promises in the wrong order. When a module used top-level await, a later import could resolve before an earlier one finished evaluating, causing code to access exports before they were initialized. Safari 27 fixes this with a fully rewritten, spec-compliant module loader.

_Track how Safari 27 resolves this JavaScript module bug on daily.dev before shipping top-level await in production._

### Is top-level await reliable in Safari now?

Yes, as of Safari 27 (available now in Safari Technology Preview 251 and the Safari 27 beta), WebKit rewrote its module loader natively in C++ following the ECMAScript specification's asynchronous module execution algorithms, rather than the outdated WHATWG Loader proposal it previously relied on. The new implementation passed all module-related test262 and WPT tests with no regressions.

_Developers weighing browser compatibility for ES modules can follow WebKit updates like this on daily.dev._

### Was Safari's old JavaScript module loader written in JavaScript or C++?

It was written in JavaScript as a self-hosted builtin, which allowed inlining into user code and faster object creation, but suffered from slower startup due to runtime compilation and less predictable performance since the module loader wasn't a hot path for JIT optimization. Safari 27's rewrite switched to fully native C++ code instead.

_Engineers debugging JS engine internals can follow implementation trade-offs like this on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@allinonetools** · 4 upvotes

> Nice to see Safari finally getting this right. Module loading bugs can be incredibly frustrating because everything looks fine until a specific browser breaks it.

**@agustinbarrientos** · 0 upvotes

> I think the regression suite should keep one minimized graph per distinct failure mode. Static and repeated dynamic imports can stay separate. When engines disagree, the fuzzer shouldn't silently assume one implementation is correct.

## Similar posts on daily.dev

- [News from WWDC26: WebKit in Safari 27 beta](https://daily.dev/posts/news-from-wwdc26-webkit-in-safari-27-beta-cz81svuy5) · WebKit · 12 upvotes · 1 comments
- [Release Notes for Safari Technology Preview 238](https://daily.dev/posts/release-notes-for-safari-technology-preview-238-nui8ncsfj) · WebKit · 0 upvotes · 0 comments
- [Release Notes for Safari Technology Preview 244](https://daily.dev/posts/release-notes-for-safari-technology-preview-244-aqbh7pydl) · WebKit · 10 upvotes · 1 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#safari](https://daily.dev/tags/safari)

[View this post on daily.dev](https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Fixing Top-Level Await in Safari","url":"https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq"},"datePublished":"2026-09-02T17:10:10.634Z","dateModified":"2026-09-14T09:11:48.896Z","description":"Safari 27's WebKit engine now fully complies with the ECMAScript spec for top-level await, fixing longstanding bugs that caused 'accessed before...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d50208ab2c6648366673f4377de21c6f?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d50208ab2c6648366673f4377de21c6f?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"WebKit","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"WebKit","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/webkit","url":"https://daily.dev/sources/webkit"},"commentCount":3,"discussionUrl":"https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":14},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":3}],"keywords":"javascript,safari","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"WebKit","item":"https://daily.dev/sources/webkit"},{"@type":"ListItem","position":3,"name":"Fixing Top-Level Await in Safari"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq","comment":[{"@type":"Comment","text":"Nice to see Safari finally getting this right. Module loading bugs can be incredibly frustrating because everything looks fine until a specific browser breaks it.","datePublished":"2026-09-03T03:22:10.418Z","url":"https://daily.dev/posts/kCSPlB3AQ#c-S1pBBzNDl","author":{"@type":"Person","name":"AllInOneTools","url":"https://daily.dev/allinonetools","image":"https://media.daily.dev/image/upload/s--4ZT8QlF0--/f_auto/v1769790028/avatars/avatar_igzBsWloJeaegzm9bQltZ?_a=BAMAMiiu0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4}},{"@type":"Comment","text":"I think the regression suite should keep one minimized graph per distinct failure mode. Static and repeated dynamic imports can stay separate. When engines disagree, the fuzzer shouldn’t silently assume one implementation is correct.","datePublished":"2026-09-04T18:29:34.632Z","url":"https://daily.dev/posts/kCSPlB3AQ#c-g2TeYpfiL","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq#faq","mainEntity":[{"@type":"Question","name":"Why did top-level await cause 'Cannot access before initialization' errors in Safari?","acceptedAnswer":{"@type":"Answer","text":"Safari's old module loader was built on the abandoned WHATWG Loader proposal from before async/await existed in ECMAScript, so it resolved import promises in the wrong order. When a module used top-level await, a later import could resolve before an earlier one finished evaluating, causing code to access exports before they were initialized. Safari 27 fixes this with a fully rewritten, spec-compliant module loader. Track how Safari 27 resolves this JavaScript module bug on daily.dev before shipping top-level await in production."}},{"@type":"Question","name":"Is top-level await reliable in Safari now?","acceptedAnswer":{"@type":"Answer","text":"Yes, as of Safari 27 (available now in Safari Technology Preview 251 and the Safari 27 beta), WebKit rewrote its module loader natively in C++ following the ECMAScript specification's asynchronous module execution algorithms, rather than the outdated WHATWG Loader proposal it previously relied on. The new implementation passed all module-related test262 and WPT tests with no regressions. Developers weighing browser compatibility for ES modules can follow WebKit updates like this on daily.dev."}},{"@type":"Question","name":"Was Safari's old JavaScript module loader written in JavaScript or C++?","acceptedAnswer":{"@type":"Answer","text":"It was written in JavaScript as a self-hosted builtin, which allowed inlining into user code and faster object creation, but suffered from slower startup due to runtime compilation and less predictable performance since the module loader wasn't a hot path for JIT optimization. Safari 27's rewrite switched to fully native C++ code instead. Engineers debugging JS engine internals can follow implementation trade-offs like this on daily.dev."}}]}
```

