From 18fd23d3c0efc06bec716c3f814141be8c323f56 Mon Sep 17 00:00:00 2001 From: pimlie Date: Sat, 9 Mar 2019 09:12:58 +0100 Subject: [PATCH] refactor: remove beforeMount hook This shouldnt be necessary anymore because we force initialization once on mounted/nextTick. Using beforeMount is also inherently less optimal because you are unlikely to benefit from walking the component tree as beforeMount is called before all child components are loaded. So using beforeMount resulted probably that for every component which uses metaInfo a refresh was called on load. A possible caveat that may exists due to removing beforeMount in favor of a single refresh is that it takes longer for your metaInfo to be updated if you have a lot of components on your page, not sure if this will be a problem in real world scenarios because if this is a problem you should probably be using ssr anyway. Also the v1 docs state that using beforeMount also results in a single update (although in practice it could be more then one) --- src/shared/mixin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/mixin.js b/src/shared/mixin.js index 1faf876..f6807a2 100644 --- a/src/shared/mixin.js +++ b/src/shared/mixin.js @@ -5,7 +5,7 @@ import { ensuredPush } from './ensure' export default function createMixin(Vue, options) { // for which Vue lifecycle hooks should the metaInfo be refreshed - const updateOnLifecycleHook = ['activated', 'deactivated', 'beforeMount'] + const updateOnLifecycleHook = ['activated', 'deactivated'] // watch for client side component updates return {