Skip to content

Commit

Permalink
prefetch links working
Browse files Browse the repository at this point in the history
  • Loading branch information
georges-gomes committed Sep 13, 2023
1 parent 93032a1 commit c0eff31
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@divriots/jampack",
"version": "0.15.0",
"version": "0.20.0",
"cache-version": {
"img": "v1",
"img-ext": "v1"
Expand Down
30 changes: 29 additions & 1 deletion packages/www/public/features/prefetch-links/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,32 @@ title: Prefetch links
jampack: "--onlyoptim"
---

TODO
`jampack` can prefetch links on the page for faster future navigation.

Read more about [why you need link prefetch on web.dev](https://web.dev/link-prefetch).

## Configuration

```js
{
misc: {
prefetch_links: 'in-viewport',
},
}
```

## Possible options

### `prefetch_links: 'off'`

No prefetch of links are added to the pages.

### `prefetch_links: 'in-viewport'`

`jampack` adds [quicklink](https://github.com/GoogleChromeLabs/quicklink) to all the html page.

[quicklink](https://github.com/GoogleChromeLabs/quicklink) prefetches links that appear in viewport during idle time.

> [quicklink](https://github.com/GoogleChromeLabs/quicklink) is a ~2K (minified/gzipped) Javascript module. This Javascript is asynchronously loaded by `jampack` at low priority and doesn't affect the performance of the pages. The quicklink module is loaded once by the browser and cached for new pages.
See [quicklink website](https://getquick.link/) for more information.
4 changes: 4 additions & 0 deletions packages/www/src/content/devlog/inline-critical-css.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ title: Inline critical CSS

See [Inline critical CSS](/features/inline-critical-css/) for more details.

## Limitations

Only works for relative stylesheet. I hope to improve [critters](https://github.com/GoogleChromeLabs/critters) to also support absolute stylesheet.

## Released

- `jampack 0.20.0+`
6 changes: 3 additions & 3 deletions packages/www/src/content/devlog/prefetch-links.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
date: 2023-09-04
date: 2023-09-13
author: ['georges-gomes']
title: Prefetch links
---
Expand All @@ -11,12 +11,12 @@ This makes navigation to subsequent pages load faster.
```js
{
misc: {
prefetch_links: 'in-viewport' | 'none';
prefetch_links: 'in-viewport' | 'off';
}
}
```

- `none`: No prefetch of links.
- `off`: No prefetch of links.
- `in-viewport`: Links are prefetched when entering viewport.

See [Prefetch links](/features/prefetch-links/) for more details.
Expand Down
2 changes: 1 addition & 1 deletion src/config-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const default_options: Options = {
},
},
misc: {
prefetch_links: 'none',
prefetch_links: 'off',
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ export type Options = {
};
};
misc: {
prefetch_links: 'in-viewport' | 'none';
prefetch_links: 'in-viewport' | 'off';
};
};

0 comments on commit c0eff31

Please sign in to comment.