diff --git a/build/fetch-jsonp.js b/build/fetch-jsonp.js index 064007b..8826a0a 100644 --- a/build/fetch-jsonp.js +++ b/build/fetch-jsonp.js @@ -87,6 +87,10 @@ if (options.crossorigin) { jsonpScript.setAttribute('crossorigin', 'true'); } + var fp = options.fetchPriority; + if (fp === 'high' || fp === 'low' || fp === 'auto') { + jsonpScript.setAttribute('fetchPriority', fp); + } jsonpScript.id = scriptId; document.getElementsByTagName('head')[0].appendChild(jsonpScript); diff --git a/index.d.ts b/index.d.ts index 1721976..0904151 100644 --- a/index.d.ts +++ b/index.d.ts @@ -9,6 +9,7 @@ declare namespace fetchJsonp { crossorigin?: boolean; referrerPolicy?: ReferrerPolicy; charset?: string; + fetchPriority?: 'high' | 'low' | 'auto'; } interface Response { diff --git a/src/fetch-jsonp.js b/src/fetch-jsonp.js index b4f05bb..b004c08 100644 --- a/src/fetch-jsonp.js +++ b/src/fetch-jsonp.js @@ -68,6 +68,10 @@ function fetchJsonp(_url, options = {}) { if (options.crossorigin) { jsonpScript.setAttribute('crossorigin', 'true'); } + const fp = options.fetchPriority; + if (fp === 'high' || fp === 'low' || fp === 'auto') { + jsonpScript.setAttribute('fetchPriority', fp); + } jsonpScript.id = scriptId; document.getElementsByTagName('head')[0].appendChild(jsonpScript);