Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does vue take over a prerendered page?

Tags:

vue.js

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.

like image 329
Eric Guan Avatar asked Nov 07 '17 06:11

Eric Guan


1 Answers

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.

like image 147
ProblemsOfSumit Avatar answered Oct 31 '22 21:10

ProblemsOfSumit