Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"json" as the fetch destination for json modules is inconsistent with regular json fetches #10231

Closed
noamr opened this issue Mar 29, 2024 · 5 comments

Comments

@noamr
Copy link
Contributor

noamr commented Mar 29, 2024

What is the issue with the HTML Standard?

Following the discussion in #7233, I understand why JSON modules don't have a script destination. However, it's unclear to me why they should have a destination different from regular fetch (i.e. the empty string, orSec-Fetch-Dest: empty. Seems like imported json modules are no different from calling (await fetch()).json() ?

This means, for example, that you need to preload the same JSON file differently if you use it in a fetch vs if you use it in an import, and that doesn't seem right.

@nicolo-ribaudo @annevk

@annevk
Copy link
Member

annevk commented Mar 29, 2024

That's true for style sheets or scripts too. I think this is working as designed.

@noamr
Copy link
Contributor Author

noamr commented Mar 29, 2024

That's true for style sheets or scripts too. I think this is working as designed.

Classic script and module scripts have the script destination.
Regular CSS and CSS modules have the style destination.
fetch(json) and import(json) don't have the same destination.

Am I missing something?

@annevk
Copy link
Member

annevk commented Mar 29, 2024

You need to compare fetch(css) and fetch(json).

@noamr
Copy link
Contributor Author

noamr commented Mar 29, 2024

That's true for style sheets or scripts too. I think this is working as designed.

Classic script and module scripts have the script destination. Regular CSS and CSS modules have the style destination. fetch(json) and import(json) don't have the same destination.

Am I missing something?

Does this mean to say that JSON modules are somehow semantically a different thing

You need to compare fetch(css) and fetch(json).

OK, closing. We still need to support style and json in modulepreload, will open a separate ticket.

@noamr noamr closed this as completed Mar 29, 2024
@annevk
Copy link
Member

annevk commented Mar 30, 2024

It's semantically somewhat distinct yes. With fetch() you don't know what you're fetching. With JSON modules you do. If we had a <json src> element it would presumably also use the json destination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants