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: sort critical tags and sort opt-in renderPriority #89

Merged
merged 9 commits into from Sep 18, 2022

Conversation

harlan-zw
Copy link
Collaborator

@harlan-zw harlan-zw commented Sep 15, 2022

Problem

There are two problems which overlap:

  1. There are certain HTML tags that are critical to be rendered first, these include:
  • <base> Must be rendered before any tags with href=".."
  • <meta charset...> To avoid encoding issues it should come before any text which may not match the default encoding
  • <meta http-equiv="content-security-policy"> Needs to come before any scripts
  1. Users want to be able to change the order of tags, see Question: how to prioritize some link tags above others #86, Option for ordering in head? font faces loaded before fonts are loaded, results in annoying warning #58

Solution

Sorting the tags is fairly straightforward, for SSR. Which is what the below PR supports.

Things get a bit complicated for client rendering due to how the DOM patching is working. Without re-working the existing patching logic it's not possible to order the tags between Vue node instances. Sorting within the node instance is possible but not as useful to the end user.

Even though non-SSR does not work, the feature is still useful, ordering meta tags is mostly an SEO optimisation in which most people would be using some SSR hybrid rendering strategy for.

@harlan-zw harlan-zw changed the title feat: default sorting of critical tags and opt-in sort renderPriority feat: default sorting of critical tags and SSR opt-in renderPriority Sep 15, 2022
@harlan-zw harlan-zw changed the title feat: default sorting of critical tags and SSR opt-in renderPriority feat: sort critical tags and SSR opt-in renderPriority Sep 15, 2022
@harlan-zw harlan-zw changed the title feat: sort critical tags and SSR opt-in renderPriority feat: sort critical tags and sort opt-in renderPriority Sep 15, 2022
@harlan-zw
Copy link
Collaborator Author

FYI I have merged #88 into this branch so there's no conflict once that's merged

@antfu antfu merged commit 839f781 into vueuse:main Sep 18, 2022
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.

None yet

2 participants