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

feat: inject module scripts into head instead of body (fixes #881) #882

Merged
merged 1 commit into from
Oct 23, 2020

Conversation

dominikg
Copy link
Contributor

@dominikg dominikg commented Oct 5, 2020

not sure if this should be configurable or if body should be used as a fallback in case head does not exist.

@yyx990803 yyx990803 merged commit 28678a9 into vitejs:master Oct 23, 2020
@isaacl
Copy link
Contributor

isaacl commented Nov 10, 2020

I disagree with this PR as it's not respecting the users template. If the user wants script in head, the template should have the script in head to start with.

I filed #1050 but it was closed.

Google web developer suggests

<head>
  <link rel="modulepreload" href="super-critical-stuff.mjs">
</head>
[...]
<script type="module" src="super-critical-stuff.mjs">

isaacl added a commit to isaacl/vite that referenced this pull request Nov 11, 2020
- injectPreload for entry chunk
- move script injection back to end of body (reverts vitejs#882)
- fix indentation of injectPreload, injectCSS and injectScript

Fixes vitejs#1050, see also vitejs#881.
isaacl added a commit to isaacl/vite that referenced this pull request Nov 11, 2020
- injectPreload for entry chunk
- move script injection back to end of body (reverts vitejs#882)
- fix indentation of injectPreload, injectCSS and injectScript

Fixes vitejs#1050, see also vitejs#881.
@wangcongyi
Copy link

I disagree too, eg: I want something config js or sdk js into root/index.html,
but after build. Always execute the head script first
#881 and #882
discussions

@dominikg
Copy link
Contributor Author

@wangcongyi this PR was for vite 1.0, it is no longer relevant for 2.0.
The html plugin adds rel=modulepreload to head now and the recently released vite 2.5.0 also adds a polyfill for modulepreload

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

Successfully merging this pull request may close these issues.

7 participants