Skip to content

Add preload CSS/JS support #2957

@koitsu

Description

@koitsu

Problem

Due to HTTP pipelining, content of a web page can be loaded/rendered before subsequent CSS files have been loaded. The end result is a semi-rendered page that "shifts" or "shimmers" once the CSS finishes loading / other CSS file fetches are completed. The same can apply to JavaScript.

HTML <link rel="preload"> solves this problem and is well-supported in all major browesrs (going back many, many versions). Reading Speculative loading may also provide additional benefits. (Note: do not mix up "preload" and "prefetch"! They are very different; in general "prefetch" is not needed these days.)

mdBook currently does not support a way to use preloading, which will result in the aforementioned behaviour.

Proposed Solution

Offer a way via TOML config to enable HTML link preloading. A default value of false (disabled) would be perfectly reasonable (i.e. retain existing behaviour).

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement or feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions