Web - Prerendering / Snapshoting (Dynamic to Static Web Site Generation)

About

Prerendering is a web static generator method that will take a dynamic website and turn it into a static web application.

You then don't need a server.

The website (called a progressive static site) is created at build time via a static site generator where every statically exported HTML page is an entry point to the full application.

Method

Built time

The page is created at built time.

Example with React: see React - Server-rendered markup (renderToString)

Crawling

The principle is:

  • Starts a local webserver,
  • Crawl it with a headless browser
  • Export each URL (route) as a static HTML file with a folder structure mirroring the structure of the routes.

Use case

There are some use-cases where prerendering might not be a great idea.

  • Tons of routes - If your site has hundreds or thousands of routes, it could take ages.
  • Dynamic Content - If your render routes that have content that's specific to the user viewing it or other dynamic sources, you should make sure you have placeholder components that can display until the dynamic content loads on the client-side. Otherwise it might be a tad weird.

List

Name Headless browser used Create React App Support
React Snap pupetteer Yes
react-snapshot jsdom Yes
prerender-spa-plugin pupetteer / jsdom WebPack
phenomic Yes
Prep PhantomJs No

A lot are present on this page: alternatives

Other:


Powered by ComboStrap