From 5e1e6651bc768e387af5040361c5850c670e4f9e Mon Sep 17 00:00:00 2001 From: Devin Mullins Date: Fri, 21 Oct 2022 11:44:44 -0700 Subject: [PATCH] Add options to modify URL and link element --- instantpage.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/instantpage.js b/instantpage.js index ff14629..ec9b56d 100644 --- a/instantpage.js +++ b/instantpage.js @@ -232,6 +232,10 @@ function isPreloadable(linkElement) { } function preload(url) { + if (typeof instantUrlModifier === 'function') { + url = instantUrlModifier(url); + } + if (prefetches.has(url)) { return } @@ -239,6 +243,9 @@ function preload(url) { const prefetcher = document.createElement('link') prefetcher.rel = 'prefetch' prefetcher.href = url + if (typeof instantLinkModifier === 'function') { + instantLinkModifier(prefetcher); + } document.head.appendChild(prefetcher) prefetches.add(url)