From 4336b3e13eb2d1b7aa933889f060e792a2d9e6b1 Mon Sep 17 00:00:00 2001 From: pimlie Date: Wed, 26 Feb 2020 19:42:18 +0100 Subject: [PATCH] docs: clarify once/skip usage --- docs/api/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/api/README.md b/docs/api/README.md index 88e3f64..890d80b 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -614,6 +614,8 @@ These attributes define specific features when used in a metaInfo property When adding a metaInfo property that should be added once without reactivity (thus will never be updated) you can add `once: true` to the property. +> `once` only works reliably during SSR. When using `once` in components, you need to also use `skip` and store a skip status outside of the component scope. + ```js { metaInfo: { @@ -625,6 +627,24 @@ When adding a metaInfo property that should be added once without reactivity (th } } ``` +or in combination with `skip` +```js +let theJsHasBeenAddedSoSkipIt = false // <-- outside the component scope + +export default { + ... + head() { + const skip = theJsHasBeenAddedSoSkipIt + theJsHasBeenAddedSoSkipIt = true + + return { + script: [ + { once: true, skip, src: '/file.js' } + ] + } + } +} +``` ### skip