Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fetch-inject

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-inject - npm Package Compare versions

Comparing version 1.6.12 to 1.6.13

38

dist/fetch-inject.es.js

@@ -0,5 +1,16 @@

/*! Fetch Inject v1.6.13 | (c) 2017 Josh Habdas | @license ISC */
/**
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @license ISC
* Copyright (c) 2017, Josh Habdas
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

@@ -10,3 +21,22 @@

/**
* ISC License
*
* Copyright (c) 2017, Josh Habdas
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
* Fetch Inject module.
*
* @module fetchInject

@@ -40,3 +70,3 @@ * @param {(USVString[]|Request[])} inputs Resources you wish to fetch.

thenables.push({ then: resolve => {
resource.blob.type === 'text/css'
resource.blob.type.includes('text/css')
? head(window, document, 'style', resource, resolve)

@@ -43,0 +73,0 @@ : head(window, document, 'script', resource, resolve);

9

dist/fetch-inject.es.min.js

@@ -1,7 +0,2 @@

/**
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @license ISC
*/
const e=function(e,n,t,r,o,i,c){i=n.createElement(t),c=n.getElementsByTagName(t)[0],i.appendChild(n.createTextNode(r.text)),i.onload=o(r),c?c.parentNode.insertBefore(i,c):n.head.appendChild(i)},n=function(n,t){if(!n||!Array.isArray(n))return Promise.reject(new Error("`inputs` must be an array"));if(t&&!(t instanceof Promise))return Promise.reject(new Error("`promise` must be a promise"));const r=[],o=t?[].concat(t):[],i=[];return n.forEach(e=>o.push(window.fetch(e).then(e=>{return[e.clone().text(),e.blob()]}).then(e=>{return Promise.all(e).then(e=>{r.push({text:e[0],blob:e[1]})})}))),Promise.all(o).then(()=>{return r.forEach(n=>{i.push({then:t=>{"text/css"===n.blob.type?e(window,document,"style",n,t):e(window,document,"script",n,t)}})}),Promise.all(i)})};export default n;
/*! Fetch Inject v1.6.13 | (c) 2017 Josh Habdas | @license ISC */
const e=function(e,n,t,r,o,i,c){i=n.createElement(t),c=n.getElementsByTagName(t)[0],i.appendChild(n.createTextNode(r.text)),i.onload=o(r),c?c.parentNode.insertBefore(i,c):n.head.appendChild(i)},n=function(n,t){if(!n||!Array.isArray(n))return Promise.reject(new Error("`inputs` must be an array"));if(t&&!(t instanceof Promise))return Promise.reject(new Error("`promise` must be a promise"));const r=[],o=t?[].concat(t):[],i=[];return n.forEach(e=>o.push(window.fetch(e).then(e=>{return[e.clone().text(),e.blob()]}).then(e=>{return Promise.all(e).then(e=>{r.push({text:e[0],blob:e[1]})})}))),Promise.all(o).then(()=>{return r.forEach(n=>{i.push({then:t=>{n.blob.type.includes("text/css")?e(window,document,"style",n,t):e(window,document,"script",n,t)}})}),Promise.all(i)})};export default n;

@@ -0,14 +1,44 @@

/*! Fetch Inject v1.6.13 | (c) 2017 Josh Habdas | @license ISC */
var fetchInject = (function () {
'use strict';
/**
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @license ISC
* Copyright (c) 2017, Josh Habdas
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
var fetchInject = (function () {
'use strict';
const head = (function(i,s,o,g,r,a,m){a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.appendChild(s.createTextNode(g.text));a.onload=r(g);m?m.parentNode.insertBefore(a,m):s.head.appendChild(a);}); // eslint-disable-line
/**
* ISC License
*
* Copyright (c) 2017, Josh Habdas
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
* Fetch Inject module.
*
* @module fetchInject

@@ -42,3 +72,3 @@ * @param {(USVString[]|Request[])} inputs Resources you wish to fetch.

thenables.push({ then: resolve => {
resource.blob.type === 'text/css'
resource.blob.type.includes('text/css')
? head(window, document, 'style', resource, resolve)

@@ -45,0 +75,0 @@ : head(window, document, 'script', resource, resolve);

@@ -1,7 +0,2 @@

/**
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @license ISC
*/
var fetchInject=function(){"use strict";const e=function(e,t,n,r,o,i,c){i=t.createElement(n),c=t.getElementsByTagName(n)[0],i.appendChild(t.createTextNode(r.text)),i.onload=o(r),c?c.parentNode.insertBefore(i,c):t.head.appendChild(i)},t=function(t,n){if(!t||!Array.isArray(t))return Promise.reject(new Error("`inputs` must be an array"));if(n&&!(n instanceof Promise))return Promise.reject(new Error("`promise` must be a promise"));const r=[],o=n?[].concat(n):[],i=[];return t.forEach(e=>o.push(window.fetch(e).then(e=>{return[e.clone().text(),e.blob()]}).then(e=>{return Promise.all(e).then(e=>{r.push({text:e[0],blob:e[1]})})}))),Promise.all(o).then(()=>{return r.forEach(t=>{i.push({then:n=>{"text/css"===t.blob.type?e(window,document,"style",t,n):e(window,document,"script",t,n)}})}),Promise.all(i)})};return t}();
/*! Fetch Inject v1.6.13 | (c) 2017 Josh Habdas | @license ISC */
var fetchInject=function(){"use strict";const e=function(e,t,n,r,o,i,c){i=t.createElement(n),c=t.getElementsByTagName(n)[0],i.appendChild(t.createTextNode(r.text)),i.onload=o(r),c?c.parentNode.insertBefore(i,c):t.head.appendChild(i)},t=function(t,n){if(!t||!Array.isArray(t))return Promise.reject(new Error("`inputs` must be an array"));if(n&&!(n instanceof Promise))return Promise.reject(new Error("`promise` must be a promise"));const r=[],o=n?[].concat(n):[],i=[];return t.forEach(e=>o.push(window.fetch(e).then(e=>{return[e.clone().text(),e.blob()]}).then(e=>{return Promise.all(e).then(e=>{r.push({text:e[0],blob:e[1]})})}))),Promise.all(o).then(()=>{return r.forEach(t=>{i.push({then:n=>{t.blob.type.includes("text/css")?e(window,document,"style",t,n):e(window,document,"script",t,n)}})}),Promise.all(i)})};return t}();

@@ -1,7 +0,2 @@

/**
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @license ISC
*/
/*! Fetch Inject v1.6.13 | (c) 2017 Josh Habdas | @license ISC */
(function (global, factory) {

@@ -13,6 +8,41 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :

/**
* Copyright (c) 2017, Josh Habdas
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
const head = (function(i,s,o,g,r,a,m){a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.appendChild(s.createTextNode(g.text));a.onload=r(g);m?m.parentNode.insertBefore(a,m):s.head.appendChild(a);}); // eslint-disable-line
/**
* ISC License
*
* Copyright (c) 2017, Josh Habdas
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
* Fetch Inject module.
*
* @module fetchInject

@@ -46,3 +76,3 @@ * @param {(USVString[]|Request[])} inputs Resources you wish to fetch.

thenables.push({ then: resolve => {
resource.blob.type === 'text/css'
resource.blob.type.includes('text/css')
? head(window, document, 'style', resource, resolve)

@@ -49,0 +79,0 @@ : head(window, document, 'script', resource, resolve);

@@ -1,7 +0,2 @@

/**
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @license ISC
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.fetchInject=t()}(this,function(){"use strict";const e=function(e,t,n,o,r,i,c){i=t.createElement(n),c=t.getElementsByTagName(n)[0],i.appendChild(t.createTextNode(o.text)),i.onload=r(o),c?c.parentNode.insertBefore(i,c):t.head.appendChild(i)},t=function(t,n){if(!t||!Array.isArray(t))return Promise.reject(new Error("`inputs` must be an array"));if(n&&!(n instanceof Promise))return Promise.reject(new Error("`promise` must be a promise"));const o=[],r=n?[].concat(n):[],i=[];return t.forEach(e=>r.push(window.fetch(e).then(e=>{return[e.clone().text(),e.blob()]}).then(e=>{return Promise.all(e).then(e=>{o.push({text:e[0],blob:e[1]})})}))),Promise.all(r).then(()=>{return o.forEach(t=>{i.push({then:n=>{"text/css"===t.blob.type?e(window,document,"style",t,n):e(window,document,"script",t,n)}})}),Promise.all(i)})};return t});
/*! Fetch Inject v1.6.13 | (c) 2017 Josh Habdas | @license ISC */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.fetchInject=t()}(this,function(){"use strict";const e=function(e,t,n,o,r,i,c){i=t.createElement(n),c=t.getElementsByTagName(n)[0],i.appendChild(t.createTextNode(o.text)),i.onload=r(o),c?c.parentNode.insertBefore(i,c):t.head.appendChild(i)},t=function(t,n){if(!t||!Array.isArray(t))return Promise.reject(new Error("`inputs` must be an array"));if(n&&!(n instanceof Promise))return Promise.reject(new Error("`promise` must be a promise"));const o=[],r=n?[].concat(n):[],i=[];return t.forEach(e=>r.push(window.fetch(e).then(e=>{return[e.clone().text(),e.blob()]}).then(e=>{return Promise.all(e).then(e=>{o.push({text:e[0],blob:e[1]})})}))),Promise.all(r).then(()=>{return o.forEach(t=>{i.push({then:n=>{t.blob.type.includes("text/css")?e(window,document,"style",t,n):e(window,document,"script",t,n)}})}),Promise.all(i)})};return t});
{
"name": "fetch-inject",
"version": "1.6.12",
"version": "1.6.13",
"description": "Dynamically inline assets into the DOM using Fetch Injection.",

@@ -5,0 +5,0 @@ "author": "Josh Habdas <josh@habd.as> (https://habd.as/)",

@@ -29,3 +29,3 @@ <h1 align="center">Fetch Inject</h1>

This library implements a performance optimization technique known as _Fetch Injection_ for [managing async dependencies with JavaScript](https://hackcabin.com/post/managing-async-dependencies-javascript/). It also works for stylesheets too, and was designed to be extensible for _any_ resource type which can be loaded using [`fetch`](https://devdocs.io/dom-fetch/).
This library implements a performance optimization technique [known as](https://hackcabin.com/post/managing-async-dependencies-javascript/) _Fetch Injection_ for managing async dependencies with JavaScript. It also works for stylesheets too, and was designed to be extensible for _any_ resource type which can be loaded using [`fetch`](https://devdocs.io/dom-fetch/).

@@ -32,0 +32,0 @@ Use Fetch Inject to dynamically import page resources such as JS and CSS in parallel (even across the network), and load them into your page in a desired sequence.

@@ -15,3 +15,3 @@ import uglify from 'rollup-plugin-uglify'

license({
banner: `Fetch Inject v<%= pkg.version %>\nCopyright (c) <%= moment().format('YYYY') %> Josh Habdas\n@license ISC`
banner: `/*! Fetch Inject v<%= pkg.version %> | (c) <%= moment().format('YYYY') %> Josh Habdas | @license ISC */`
})

@@ -18,0 +18,0 @@ ]

@@ -0,1 +1,19 @@

/**
* ISC License
*
* Copyright (c) 2017, Josh Habdas
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
import {

@@ -7,2 +25,3 @@ head as injectHead

* Fetch Inject module.
*
* @module fetchInject

@@ -36,3 +55,3 @@ * @param {(USVString[]|Request[])} inputs Resources you wish to fetch.

thenables.push({ then: resolve => {
resource.blob.type === 'text/css'
resource.blob.type.includes('text/css')
? injectHead(window, document, 'style', resource, resolve)

@@ -39,0 +58,0 @@ : injectHead(window, document, 'script', resource, resolve)

@@ -0,1 +1,17 @@

/**
* Copyright (c) 2017, Josh Habdas
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
export const head = (function(i,s,o,g,r,a,m){a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.appendChild(s.createTextNode(g.text));a.onload=r(g);m?m.parentNode.insertBefore(a,m):s.head.appendChild(a)}) // eslint-disable-line
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc