Skip to content

Commit 9c31799

Browse files
authored
Create prefetch.md
1 parent 0196d39 commit 9c31799

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Prefetch
3+
---
4+
<Since versions={[ 3.9 ]} />
5+
6+
Assets including strings, and templates, can be pre-fetched shortly after the page loads to improve the perceived performance of the page when consuming those components.
7+
8+
```todo
9+
Link to jsdocs here
10+
```
11+
12+
```js title="Example of fetching a string and template"
13+
import Prefetch from 'core/prefetch';
14+
15+
// Prefetch the string 'discussion' from the 'mod_forum' component.
16+
Prefetch.prefetchString('discussion', 'mod_forum');
17+
18+
// Prefetch the strings yes, no, and maybe from the 'core' component.
19+
Prefetch.prefetchStrings('core', ['yes', 'no', 'maybe']);
20+
21+
// Prefetch the templates 'core/toast'.
22+
Prefetch.prefetchTemplate('core/toast');
23+
24+
// Prefetch the templates 'core/toast' and 'core/modal'.
25+
Prefetch.prefetchTemplates(['core/toast', 'core/modal']);
26+
```

0 commit comments

Comments
 (0)