Giter Site home page Giter Site logo

ssg-playground's Introduction

ssg-playground

Testing ground for server-side-generation (SSG) feature in modern server-side frameworks.

What is this repo?

This repo was made for practice and comparison of tools that may be used for building modern, dynamic webpages that utilize server server side rendering at build time. Tested frameworks include: Next.js, GatsbyJS, Sapper and Nuxt.js.

What can I find in here?

./next-app, ./gatsby-app, ./sapper-app, ./nuxt-app directories contain code written using Next.js, GatsbyJS, Sapper and Nuxt.js respectively.

./mocks - json databse hosted by json-server with data used for generating pages.

What's the app then?

A simple blog post. Nothing fancy. The following fetures were taken into account:

  • index page with list of posts injected at build time
  • fully static pages - about and 404
  • dynamic blog post pages - paths generated at build time
  • common layout, but applied only to selected pages
  • client-side only content - blog post comments

How to run

To serve mock data (required for building), run npm run serve-mocks. To build all static versions of pages, run npm run build. To serve staticly generated pages, run npm run serve.

Apps are served at ports 4000-4003 respectively.

Conclusions and remarks

  • Although only gatsby is completly dedicated for SSG, all frameworks allowed for acomplishing the task and meeting the requirements.
  • Using data hosted by REST api (mock server in this case) turned to be a bit tricker when using gatsby. Failed to utilize data-source plugins adapting rest apis (however, could be my mistake). Using createPage turned out to be the way - generating pages was then as easy as in other frameworks.
  • Only pages generated using next and gatsby may be deployed without serving the content separately. Sapper and Nuxt does include the data into the exported public files, but on client-side navigation it fetches the original data source (same as at build time).
  • Sapper provides an internal isomorphic fetch function, which may be considered also a benefit (no need to install it separately).

Lighthouse audit comparison (mobile)

Note: websites were not optimized for audit, tests were run on pages as they are. Results could be propably easily improved.

Next.js Gatsby.js Sapper Nuxt.js
performance 96 96 100 97
accessibility 91 95 100 91
best practices 93 93 93 93
SEO 100 100 100 100
first contentful paint 2.0s 2.3s 1.4s 1.2s
first meaningful paint 2.0s 2.3s 1.4s 1.2s
time to interactive 3.0s 2.3s 1.4s 3.3s
first cpu idle 2.0s 3.1s 1.4s 3.3s
--- --- --- --- ---
additional: data transfer on load 221kB 326kB 43kB 259kB

ssg-playground's People

Contributors

grzegorzkazana avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.