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

(X)HTML import name suggestion #38

Open
ghost opened this issue Sep 20, 2020 · 6 comments
Open

(X)HTML import name suggestion #38

ghost opened this issue Sep 20, 2020 · 6 comments

Comments

@ghost
Copy link

ghost commented Sep 20, 2020

Unless I am mistaken, it is currently being proposed that ECMAScript be able to use MJS syntax for imports, and (X)HTML to use a module script tag?

For the MJS part, I have no opinion, for the (X)HTML web page it is being suggested that we could use something along the lines of:

<script type="module" src="./main.wasm" />

If so, might I suggest that we look at how JavaScript was originally intended to be imported:

<script type="text/javascript" src="./main.js" />

Google's Dartium browser used the Dart mime for executing Dart:

<script type="application/dart" src="./main.dart" />

Thus, shouldn't we use the Wasm mime-type as the "type" in (X)HTML?

This would make it much clearer to the developer, be clearer to the browser, and be better compatibility-wise: older browsers would not attempt to request the file at all, only newer browsers would. Even a current browser would expect JavaScript, thus waste client resources just to error upon seeing Wasm bytecode.

Unless this proposal is purely for a more ergonomic syntax when used in modules.

@ExE-Boss
Copy link

I believe that using:

<script type="application/wasm" src="./main.wasm" />

Is probably the best approach, given that WebAssembly files are always modules.

@devsnek
Copy link
Member

devsnek commented Nov 29, 2020

I would assume that <script type="module">, should work for anything the browser knows how to import using esm.

@ghost
Copy link
Author

ghost commented Nov 30, 2020

I would assume that <script type="module">, should work for anything the browser knows how to import using esm.

I could see that making sense, but would it be at least permitted to use the Wasm MIME type?

In my opinion, seeing the Wasm MIME is more readable, and others may find that it makes more sense too, but if we have to use module for everything, I guess that's fine too.

@ExE-Boss
Copy link

ExE-Boss commented Dec 1, 2020

Note that even with whatwg/html#4372, <script type="module"> is only allowed to load JavaScript modules

@ghost
Copy link
Author

ghost commented Dec 1, 2020

Note that even with whatwg/html#4372...

whatwg/html#4372 (comment)
It seems like someone had said that they would rather not see the WebAssembly MIME type used as the value of the type attribute.

@ghost
Copy link
Author

ghost commented Jun 18, 2021

It seems like no progress has veen made here, so far? Imo, anything that allows clearly distinguishing WebAssembly from JavaScript would be beneficial, at least regarding readability of the document. On top of readability, using type="wasm"is slightly shorter than "module," thus more ergonomic, and would also help with file storing and serving documents over the network by being (slightly) more compact.

I do believe the situation that I had initially raised, that is, consumption of user resources in order to request Wasm, which a browser would always fail to load, is a valid reason to make the explicit distinction. Do the authors of the proposal agree?

On the other hand, if type="module" is what will be used, feel free to close the issue.

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

No branches or pull requests

2 participants