Skip to content

Proposal: Hydrate #223

Open
Open
@MartinKavik

Description

@MartinKavik

Motivation

Flashing page elements on wasm file load on prerendered pages.

How to reproduce

Try to open kavik.cz/about/ on a mobile or in a desktop browser with enabled throttling in dev tools. The first you see prerendered html and once the wasm is loaded, the entire page is rerendered which causes flashes.

Problem

This code: https://github.com/MartinKavik/kavik.cz/blob/master/crate/src/app.rs#L49. I have to delete root element content before render, otherwise Seed will append identical html at the end of the root.

How to resolve

Use prerendered HTML as the previously rendered HTML by Seed. So either introduce a new function hydrate or make render more intelligent (probably better option). There are examples from other frameworks: https://github.com/stereobooster/react-snap#basic-usage-with-create-react-app.

Possible implementation problems

Prerendered and rendered code isn't 100% identical, e.g. hamburger is spinner in prerendered version (see my example in section how to reproduce).

Public API changes.

None, if we update render function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions