diff --git a/src/index.mjs b/src/index.mjs index efef9ba8..cd22cfb9 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -48,6 +48,7 @@ function prefetcher(url) { * @param {Array} options.urls - Array of URLs to prefetch (override) * @param {Object} options.el - DOM element to prefetch in-viewport links of * @param {Boolean} options.priority - Attempt higher priority fetch (low or high) + * @param {Boolean} options.sameOrigin - Restrict prefetching to assets with same origin. * @param {Array} options.origins - Allowed origins to prefetch (empty allows all) * @param {Number} options.timeout - Timeout after which prefetching will occur * @param {function} options.timeoutFn - Custom timeout function @@ -62,7 +63,7 @@ export default function (options) { observer.priority = options.priority; - const allowed = options.origins || []; + const allowed = options.sameOrigin ? [location.hostname] : options.origins || []; options.timeoutFn(() => { // If URLs are given, prefetch them.