Reputation: 15982
I'm using the prerender-spa-plugin, and it works great! I'm curious on how vue manages to detect the prerendering. Why doesn't it try to render its components as usual?
I've tried searching for answers but no one is discussing how vue accomplishes this.
Upvotes: 6
Views: 436
Reputation: 460
The HTML produced by Prerendering is similar to that produced by Vue SSR. The documentation for Vue SSR explains how Vue hydrates that pre-rendered HTML, I think that might be the explanation you're looking for.
Upvotes: 0
Reputation: 46
Umm I will try to answer the best I can.
Upvotes: 0
Reputation: 21325
As far as I know, Javascript kicks in as usual and renders the components. But, the page includes the rendered output before already. So it's basically the default HTML if the user has no JS enabled. After JS parses, the DOM (or the applications root div
) is emptied and the apps components are rendered as usual.
The prefilled output (HTML) is without CSS and images, but as those chunks are loaded on your page as well (hopefully fast and successful), everything is styled and beautiful, ready to be looked at.
Upvotes: 1