Is there any significant performance difference in using {compileTemplate}
from @vue/compiler-sfc
to pre-compile the render function, vs. simply using the template directly in createAppSSR()
, during the hydration step of SSR?
I am working on server side rendering for statically generated sites, and am wondering if the increase in complexity in using the lower level API is worth the performance increase, if any. Or perhaps, which use cases would fit using compileTemplate
.
Option 1: Use compileTemplate
to compile some template to obtain the render()
function, thereafter, use it in the creation of the Vue application instance in SSR Hydration mode.
const compiled = compileTemplate({
source: pageContent,
filename: XXX,
id: YYY,
});
// compiled.code contains module that exports render()
const app = createSSRApp({
render: renderFunction,
...
});
app.mount('#app');
vs. Option 2: Just use template directly:
const app = createSSRApp({
template: pageContent,
...
});
app.mount('#app');
This is given that both html bodies have the pageContent pre-rendered, and this is for the hydration step.
Thanks!