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

refactor!: v1 initial, CSR performance, awaitable hooks #126

Merged
merged 4 commits into from Oct 10, 2022

Conversation

harlan-zw
Copy link
Collaborator

@harlan-zw harlan-zw commented Oct 9, 2022

Issue

See nuxt/nuxt#15093

Benchmark results

Before v1:

CLIENT

useHead x1000: ~4500 ms
useHead v1: 1.5ms

SERVER

useHead x1000: ~5 ms
useHead v1: ~0.04ms

v1

CLIENT

useHead x1000: ~45 ms - ~200% quicker
useHead v1: 0.5ms - ~100% quicker

SERVER

useHead x1000: ~5 ms - no change
useHead v1: ~0.04ms - no change

Summary

Client-side performance is significantly improved, most noticeably when using many reactive head entries. The code should perform 100% quicker on the client side for all uses.

However, if only a couple of useHead's is used, the performance savings is in the minimal - ~1ms saved.

This should hopefully also fix nuxt/nuxt#15093 but will need to do further benchmarking to confirm.

This also includes massive refactoring, awaitable hooks, and the basis of v1.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2022

Export Size

@vueuse/head

Name Size Diff
resolveHeadEntriesToTags 1.07 KB +1.07 KB (+100.00%) 🔺
headEntryToTags 358 B +358 B (+100.00%) 🔺
resolveUnrefHeadInput 184 B +184 B (+100.00%) 🔺
IS_BROWSER 87 B +87 B (+100.00%) 🔺
renderHeadToString 1.83 KB +875 B (+87.50%) 🔺
resolveHeadEntry 228 B +16 B (+7.55%) 🔺
createHead 2.37 KB +145 B (+6.36%) 🔺
Head 559 B +28 B (+5.27%) 🔺
useHead 261 B +1 B (+0.38%) 🔺
useHeadRaw 271 B -1 B (-0.37%) 🔽
Unchanged

@vueuse/head

Name Size Diff
createElement 233 B -
escapeHtml 104 B -
escapeJS 152 B -
injectHead 162 B -
isEqualNode 183 B -
setAttrs 219 B -
sortTags 185 B -
stringifyAttrName 109 B -
stringifyAttrs 403 B -
stringifyAttrValue 193 B -
tagDedupeKey 287 B -
tagToString 661 B -
updateElements 774 B -

@harlan-zw harlan-zw changed the title performance: rewrite reactivity for SSR / CSR performance!: rewrite reactivity for SSR / CSR Oct 10, 2022
@harlan-zw harlan-zw changed the base branch from main to v1 October 10, 2022 03:05
@harlan-zw harlan-zw changed the title performance!: rewrite reactivity for SSR / CSR refactor!: rewrite for improved reactivity for SSR / CSR Oct 10, 2022
@harlan-zw harlan-zw changed the title refactor!: rewrite for improved reactivity for SSR / CSR refactor!: improved reactivity for SSR / CSR Oct 10, 2022
@harlan-zw harlan-zw changed the title refactor!: improved reactivity for SSR / CSR refactor!: performance fixes for CSR, awaitable hooks Oct 10, 2022
@harlan-zw harlan-zw changed the title refactor!: performance fixes for CSR, awaitable hooks performance!: v1 initial, rewrite reactivity for SSR / CSR Oct 10, 2022
@harlan-zw harlan-zw changed the title performance!: v1 initial, rewrite reactivity for SSR / CSR refactor!: v1 initial, CSR performance, awaitable hooks Oct 10, 2022
@harlan-zw harlan-zw merged commit 691bcc8 into v1 Oct 10, 2022
harlan-zw added a commit that referenced this pull request Nov 12, 2022
* refactor!: v1 initial, CSR performance, awaitable hooks (#126)

* performance: rewrite reactivity for SSR / CSR

* chore: rolleback artifacts

* chore: progress commit

* fix: use ./src import

* refactor!: simplify utils for smaller pkg (#127)

* performance: rewrite reactivity for SSR / CSR

* chore: rolleback artifacts

* chore: progress commit

* fix: use ./src import

* refactor: simplify util code for smaller payload

* refactor!: continued (#128)

* performance: rewrite reactivity for SSR / CSR

* chore: rolleback artifacts

* chore: progress commit

* fix: use ./src import

* refactor: simplify util code for smaller payload

* wip: part two of refactor

* chore: fix tests

* chore: run github ci on v1

* chore: run github ci on v1

* chore: bump version

* Release v1.0.0-rc.0

* Release v1.0.0-rc.1

* fix: ensure empty attrs reset attrs (#130)

* fix: ensure empty attr is set

* fix: test valid tags

* fix(ci): release on rc

* Release v1.0.0-rc.2

* fix(ci): remove broken --pre

* Release v1.0.0-rc.3

* fix(ci): use --pre

* fix: use simpler API for tags (#131)

* feat: improved hook api (#132)

* chore: prefer runtime prop for id & position (#134)

* chore: prefer runtime prop for id & position

* fix: type errors

* fix: add `headTags` for backwards compatibility (#133)

* Release v1.0.0-rc.4

* fix: add legacy `addHeadObjs` (#135)

* refactor!: useHeadRaw -> useHeadSafe (#136)

* refactor!: useHeadRaw -> useHeadSafe

* feat: tree-shake encoding

* chore: useHeadSafe types

* Release v1.0.0-rc.5

* fix(types): export `MaybeComputedRef`

* chore: add missing `type`

* Release v1.0.0-rc.6

* chore(pkg): bump deps

* fix(titleTemplate): allow titleTemplate to resolve the title (#137)

* fix(titleTemplate): allow titleTemplate to resolve the title

* chore: add happy case

* chore: fix type issues

* chore: maybe fix type issue

* chore: maybe fix type issue

* chore: maybe fix type issue

* chore: maybe fix type issue

* Release v1.0.0-rc.7

* chore: bump deps

* chore: test issue #138

* chore: linting

* chore(pkg): bump deps

* Release v1.0.0-rc.8

* fix: ensure tags props are immutable (#139)

* Release v1.0.0-rc.9

* chore(pkg): bump deps

* Release v1.0.0-rc.10

* fix: ensure single pass of `htmlAttr` sanitization, fixes #142 (#143)

* fix: ensure csr elements are created equally (#145)

* fix: ensure csr elements are created equally

* fix: remove sanitising

* chore: fix doc

* chore(pkg): bump deps

* Release v1.0.0-rc.11

* fix: vue 2.7 globalProperties, fixes #141

* chore(pkg): bump zhead

* Release v1.0.0-rc.12

* add vue 2.7 compatibility to Head component (#147)

* add vue 2.7 compatibility to Head component

* remove vue-demi in favor of checking version from vue itself

* chore(pkg): bump deps

* fix: dedupe `htmlAttrs` and `bodyAttrs` for csr (#149)

* Release v1.0.0-rc.13

* fix: Vue 2.7 compatibility (#150)

* add separate vue2 plugin for 2.7 compatibility

* Vue 2.7 install readme

* fix: handle style / class attrs

* chore: add link back to pinia

* chore: vue2 example

Co-authored-by: Val Trubachev <val.trubachev@zoro.com>

* chore(pkg): ignore eslint in vue2 example

* Release v1.0.0-rc.14

* feat: migrate core to unhead (#157)

* feat: migrate core to unhead

* chore: fix SSR test with timeouts

* chore: readme link fix

* chore(pkg): bump deps

* chore(ci): switch to next channel

* chore: document install

* Release v1.0.0-next.1

* chore: improve doc

* chore: bump unhead, update tests and examples

* Release v1.0.0-next.2

* chore: bump unhead

* chore: expose `VueHeadMixin`

* Release v1.0.0-next.3

Co-authored-by: Valera Trubachev <vetruvet@gmail.com>
Co-authored-by: Val Trubachev <val.trubachev@zoro.com>
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

1 participant