GoogleChromeLabs / GoogleChromeLabs/quicklink
Facilitate async loading of quicklink.umd.js
- Dominant language
- JavaScript
- Stars
- 11.3k
- Forks
- 429
- PR merge metrics
- No merged PRs in 30d
Description
Currently the readme suggests to include the script into the page via:
```html
quicklink();
```
or at `load` event via:
```html
window.addEventListener('load', () =>{
quicklink();
});
```
However, shouldn't the `quicklink.umd.js` script be loaded with `async` to begin with? The blocking script is not good for performance.
Ideally you should be able to do something like this, similar to the [AMP shadow doc API](https://github.com/ampproject/amphtml/blob/master/spec/amp-shadow-doc.md#using-shadow-doc-api):
```html
(window.quicklink = window.quicklink || []).push(function(quicklink) {
quicklink();
});
// Or...
window.addEventListener('load', () =>{
(window.quicklink = window.quicklink || []).push(function(quicklink) {
quicklink();
});
});
```
Contributor guide
Assessment
This issue has not been assessed yet.