Skip to content

Conversation

@therealadityashankar
Copy link
Contributor

@therealadityashankar therealadityashankar commented Nov 1, 2025

Description

I added the await-import syntax for completeness sake, I believe this syntax is likely to be used in the await-import syntax much more as compared to it's use on the top-level (I can be mistaken), due to it being simpler compared to fetching an object and converting it into json

Motivation

I suspect people are far more likely to use the await-import syntax as a replacement to fetch() due to fewer lines of code, as opposed to using import at the top level

Additional details

this simply adds the same top-level import specifications as await-imports as well

so for example

import data from "https://example.com/data.json" with { type: "json" };

can also be

const data = await import("https://example.com/data.json", { with: { type: "json" } });

I added the await-import syntax for completeness sake, I believe this syntax is likely to be used in the await-import syntax much more as compared to it's use on the top-level (I can be mistaken), due to it being simpler compared to fetching an object and converting it into json
@therealadityashankar therealadityashankar requested a review from a team as a code owner November 1, 2025 21:43
@therealadityashankar therealadityashankar requested review from Josh-Cena and removed request for a team November 1, 2025 21:43
@github-actions github-actions bot added Content:JS JavaScript docs size/s [PR only] 6-50 LoC changed labels Nov 1, 2025
…dex.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@therealadityashankar
Copy link
Contributor Author

more stuff needs to be added via @jakearchibald 's article, because the behavior here isn't what one would want, tagging that here https://jakearchibald.com/2025/importing-vs-fetching-json/

also thanks jake for writing the article

Improved it, with comments on differences between fetch and await-import
@therealadityashankar
Copy link
Contributor Author

okay, corrected it :)

…dex.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2025

Preview URLs

Flaws (2)

Note! 2 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/JavaScript/Reference/Operators/import
Title: import()
Flaw count: 2

  • broken_links:
    • /en-US/docs/Web/API/URL/createObjectURL is a redirect
    • Can't resolve /en-US/docs/Web/Node.js/vm/Module

(comment last updated: 2025-11-02 02:47:08)

Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I moved your addition to "examples" because "description" talks about the semantics of this feature while this is how you can use this feature. I also added the same kind of example to the other two relevant pages.

@Josh-Cena Josh-Cena merged commit 3d3046d into mdn:main Nov 2, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:JS JavaScript docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants