ontola / ontola/atomic-server

Improve initial page load times

Open
#511 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance
Dominant language
TypeScript
Stars
1.6k
Forks
82
Avg merge
10h 34m
Merged PRs (30d)
205

Description

Although Atomic-Server feels pretty fast most of the time, the initial load has room for improvement. This is partially due to the amount of round trips:

  1. Fetch the HTML, parse and render loading screen
  2. Fetch the JS assets, parse and execute
  3. Fetch various JSON-AD resources (including the requested page), parse and render

Include in first HTML

We could improve this by sending more data in the first HTML request:

  • include essential json ad (properties, classes). This could be either in the JS bundle or on the HTML.
  • Include the requested resource's json ad. This should probably be stored in the HTML.
  • Include (full) js bundle

Downsides of including things in the HTML:

  • the first render (of the loading screen) a bit slower. Or is HTML parsed / rendered in a streaming fashion?
  • the bundle isn't cached
  • more difficult to set up service worker (has to do with the caching above)

Include script to fetch in first HTML

In the first HTML response, include a script that fetches the JSON-AD for the requested resource + properties + classes. Parse the JSON, put it on window.atomic or something, and then when the JS is parsed, add the parsed files.

  • Doesn't slow down initial HTML response
  • Paralellizes JS + JSON-AD fetching
  • One less roundtrip!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name files, tests, or an entry point; begin by locating the initial HTML response and the code that fetches JSON-AD resources and JavaScript assets. Compare embedding data or a fetch script in the first response, and consider the listed caching and service-worker tradeoffs; done means reducing an initial round trip without losing the requested page data.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, performance, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.