最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vue.js - Is there any performance difference for SSR in compiling the template for a Vue instance - Stack Overflow

programmeradmin1浏览0评论

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!

发布评论

评论列表(0)

  1. 暂无评论