Skip to content

Commit 194881f

Browse files
committed
fix: revert options inlining;
- 689 gz / 561 br
1 parent fe5f735 commit 194881f

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/index.mjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,25 @@ function prefetcher(url) {
5252
* @param {function} options.timeoutFn - Custom timeout function
5353
*/
5454
export default function (options) {
55-
options = options || {};
55+
options = Object.assign({
56+
timeout: 2e3,
57+
priority: false,
58+
timeoutFn: requestIdleCallback,
59+
el: document,
60+
}, options);
5661

57-
observer.priority = !!options.priority;
62+
observer.priority = options.priority;
5863

59-
(options.timeoutFn || requestIdleCallback)(() => {
64+
options.timeoutFn(() => {
6065
// If URLs are given, prefetch them.
6166
if (options.urls) {
6267
options.urls.forEach(prefetcher);
6368
} else {
6469
// If not, find all links and use IntersectionObserver.
65-
Array.from((options.el || document).querySelectorAll('a'), link => {
70+
Array.from(options.el.querySelectorAll('a'), link => {
6671
observer.observe(link);
6772
toPrefetch.add(link.href);
6873
});
6974
}
70-
}, {timeout: options.timeout || 2e3});
75+
}, {timeout: options.timeout});
7176
}

0 commit comments

Comments
 (0)