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

Should Embroider passthrough script attributes? #456

Closed
bobisjan opened this issue May 19, 2020 · 5 comments · Fixed by #1605
Closed

Should Embroider passthrough script attributes? #456

bobisjan opened this issue May 19, 2020 · 5 comments · Fixed by #1605

Comments

@bobisjan
Copy link
Contributor

Hi,

should Embroider passthrough the HTML attributes like defer on scripts from app/index.html into dist/index.html for ember build --environment=production?

<!-- app/index.html -->
<script src="{{rootURL}}assets/vendor.js" defer></script>
<script src="{{rootURL}}assets/embroider-playground.js" defer></script>

<!-- dist/index.html -->
<script src="/assets/vendor.js"></script>
<script src="/assets/chunk.c1fdfc6b793b9d023c96.js"></script>
<script src="/assets/chunk.4aecffffbd029f26d4de.js"></script>

Thanks ☺️


Just for curiosity why the assets/embroider-playground.js is split into two chunks by default?

@ef4
Copy link
Contributor

ef4 commented May 19, 2020

In general, yes, we should leave attributes like defer alone.

However, I don't think that actually works reliably in Ember apps in general, with or without embroider. vendor.js must execute before the app, and if you defer both there is a chance that the app will lose the race.

Just for curiosity why the assets/embroider-playground.js is split into two chunks by default?

Webpack's default settings put things from node_modules in a separate chunk from your own project. It's the same reason Ember traditionally splits things into vendor.js and app.js -- the third-party deps are theoretically more slowly changing and can get better cacheability.

Under embroider, we will have some legacy things in vendor.js, but much of what was in there has moved into the node_modules chunk.

@bobisjan
Copy link
Contributor Author

@ef4, thanks for the explanation 👍

However, I don't think that actually works reliably in Ember apps in general, with or without embroider. vendor.js must execute before the app, and if you defer both there is a chance that the app will lose the race.

This makes me worried 🙈, where does this come from? I live with the following statement

Scripts with the defer attribute will execute in the order in which they appear in the document.

from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script.

@ef4
Copy link
Contributor

ef4 commented May 19, 2020

Oops, never mind me, I was mixed up with async.

@rahulk94
Copy link

Hey team any updates on this? I'm trying to set type="module" attributes on our application scripts so we can avoid loading them on IE but they're not propagating through. At this point I'm having difficulty figuring out whether this is an embroider issue or ember-auto-import.

@lifeart
Copy link
Collaborator

lifeart commented Jan 11, 2022

Hi @rahulk94! I think only tests is missing in original PR to move it forward

chancancode added a commit to chancancode/embroider that referenced this issue Sep 19, 2023
This ensures user-defined attributes on `<script>` and `<link>`
tags in the compat `index.html` are propagated to the final HTML
file.

Fixes embroider-build#456

Co-authored-by: Jan Bobisud <[email protected]>
chancancode added a commit to chancancode/embroider that referenced this issue Sep 19, 2023
This ensures user-defined attributes on `<script>` and `<link>`
tags in the compat `index.html` are propagated to the final HTML
file.

Fixes embroider-build#456

Co-authored-by: Jan Bobisud <[email protected]>
chancancode added a commit to chancancode/embroider that referenced this issue Sep 20, 2023
This ensures user-defined attributes on `<script>` and `<link>`
tags in the compat `index.html` are propagated to the final HTML
file.

Fixes embroider-build#456

Co-authored-by: Jan Bobisud <[email protected]>
chancancode added a commit to chancancode/embroider that referenced this issue Sep 20, 2023
This ensures user-defined attributes on `<script>` and `<link>`
tags in the compat `index.html` are propagated to the final HTML
file.

Fixes embroider-build#456

Co-authored-by: Jan Bobisud <[email protected]>
@ef4 ef4 closed this as completed in #1605 Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants