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

Clarify how to handle using sub resource web bundles when browsers support it, and traditional bundlers when they dont #642

Open
SinZ163 opened this issue Mar 24, 2021 · 3 comments

Comments

@SinZ163
Copy link

SinZ163 commented Mar 24, 2021

Title is a bit verbose but gets the point across.

With script tags, when module support was added, nomodule was also added so you could have both in your markup and the browsers that knew modules loaded modules and intentionally didn't load nomodules, I feel a similar pattern is needed for WebBundles.

In the chromium Origin Trial, it is mentioned that its possible in JS to do feature detection for this, but that would require having web app developers to effectively polyfill webbundles ourselves and only add the JS bundle script tag at runtime once feature detection has happened, increasing the size of the html body and adding latency when instead this feature can ship with polyfill mechanisms baked in.

@SinZ163 SinZ163 changed the title Clarify how to handle using web bundles when browsers support it, and traditional bundlers when they dont Clarify how to handle using sub resourceweb bundles when browsers support it, and traditional bundlers when they dont Mar 24, 2021
@SinZ163 SinZ163 changed the title Clarify how to handle using sub resourceweb bundles when browsers support it, and traditional bundlers when they dont Clarify how to handle using sub resource web bundles when browsers support it, and traditional bundlers when they dont Mar 24, 2021
@horo-t
Copy link
Collaborator

horo-t commented Mar 29, 2021

Introducing <script nowebbundle type=text/javascript src=bundle.js></script> could be a solution for this.

Currently we are using link elements for subresource web bundles in the Origin Trial.
But there is a discussion to use <script> elements for security reason.
So if we introduce<script type=webbundle> elements instead of <link rel=webbundle>, introducing <script nowebbundle> sounds plausible.

@horo-t
Copy link
Collaborator

horo-t commented Mar 29, 2021

CC: @littledan

@hayatoito
Copy link
Collaborator

hayatoito commented Mar 29, 2021

We don't have any special support for an unsupported environment yet. So I guess a workaround would be a general one, such as:

<script>
if (!feature_detection()) {
  const script = document.createElement('script') ;
  script.src = ".../traditional-bundle-runtime.js";
  document.body.appendChild(script);
  ...
}
</script>

This might add latency, as you mentioned.

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

No branches or pull requests

3 participants