New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.11 to 1.6.12

4

dist/fetch-inject.es.js
/**
* Fetch Inject v1.6.11
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @licence ISC
* @license ISC
*/

@@ -6,0 +6,0 @@

/**
* Fetch Inject v1.6.11
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @licence ISC
* @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.11
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @licence ISC
* @license ISC
*/

@@ -6,0 +6,0 @@

/**
* Fetch Inject v1.6.11
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @licence ISC
* @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.11
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @licence ISC
* @license ISC
*/

@@ -6,0 +6,0 @@

/**
* Fetch Inject v1.6.11
* Fetch Inject v1.6.12
* Copyright (c) 2017 Josh Habdas
* @licence ISC
* @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});
{
"name": "fetch-inject",
"version": "1.6.11",
"version": "1.6.12",
"description": "Dynamically inline assets into the DOM using Fetch Injection.",

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

@@ -8,19 +8,24 @@ <h1 align="center">Fetch Inject</h1>

<p align="center">
<a href="https://travis-ci.org/jhabdas/fetch-inject">
<img src="https://travis-ci.org/jhabdas/fetch-inject.svg?branch=master" alt="Build Status">
<a href="https://cost-of-modules.herokuapp.com/?p=fetch-inject@latest">
<img src="https://img.shields.io/badge/dependencies-0-8892BF.svg?style=flat-square" alt="Zero dependencies">
</a>
<a href="https://cdn.jsdelivr.net/fetch-inject/latest/fetch-inject.min.js">
<img src="http://img.badgesize.io/https://cdn.jsdelivr.net/fetch-inject/latest/fetch-inject.min.js?compression=gzip" alt="Compressed IIFE Release Size">
<img src="http://img.badgesize.io/https://cdn.jsdelivr.net/fetch-inject/latest/fetch-inject.min.js?compression=gzip&style=flat-square" alt="Compressed size of IIFE bundle">
</a>
<a href="https://travis-ci.org/jhabdas/fetch-inject">
<img src="https://img.shields.io/travis/jhabdas/fetch-inject.svg?style=flat-square" alt="Build Status">
</a>
<a href="https://www.npmjs.com/package/fetch-inject">
<img src="https://img.shields.io/npm/dm/fetch-inject.svg" alt="NPM downloads per month">
<img src="https://img.shields.io/npm/dm/fetch-inject.svg?style=flat-square" alt="NPM downloads per month">
</a>
<a href="https://www.npmjs.com/package/fetch-inject">
<img src="https://img.shields.io/npm/v/fetch-inject.svg" alt="Latest NPM version">
<img src="https://img.shields.io/npm/v/fetch-inject.svg?style=flat-square" alt="Latest NPM version">
</a>
</p>
<p align="center"><strong><a href="https://news.ycombinator.com/item?id=14380191">Discuss it on Hacker News</a></strong></p>
## Background
This library implements Fetch Injection, a performance optimization technique for [managing asynchronous dependencies](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 _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/).

@@ -33,3 +38,3 @@ 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.

Here are some example waterfalls using Fetch Inject.
Here are some example waterfalls using Fetch Inject, as well as links to more info and a live demo.

@@ -48,15 +53,17 @@ Loading Bootstrap 4:

For a more complex example see article titled [Putting WordPress into Hyperdrive](https://hackernoon.com/putting-wordpress-into-hyperdrive-4705450dffc2) on Hacker Noon. A **live demo** is available on [wordcamp.habd.as](http://wordcamp.habd.as/).
## WordPress Plugin
Fetch Inject has been built into a WordPress plugin, enabling the power of Fetch Injection for WordPress. Initial testing shows Fetch Injection will cause WordPress pages to load **200-300% faster** than traditional methods.
Fetch Inject has been built into a WordPress plugin, enabling Fetch Injection to work within WordPress. [Initial testing](https://hackernoon.com/putting-wordpress-into-hyperdrive-4705450dffc2) shows Fetch Injection enables WordPress to load pages **300% faster** than conventional methods.
![Hyperdrive WordPress Plugin logo](https://github.com/wp-id/hyperdrive/blob/master/logo.png)
[![Hyperdrive WordPress Plugin logo](https://github.com/wp-id/hyperdrive/blob/master/logo.png)](https://github.com/wp-id/hyperdrive)
For beta access to the plugin please visit [Hyperdrive repo](https://github.com/wp-id/hyperdrive) and drop the plugin code into your WordPress plugins directory.
Access the plugin beta [Hyperdrive repo](https://github.com/wp-id/hyperdrive) on GitHub and see the related [Hacker Noon article](https://hackernoon.com/putting-wordpress-into-hyperdrive-4705450dffc2) for more details.
## Playground
Try <a target="_blank" rel="noreferrer noopener" href="https://codepen.io/jhabdas/pen/MpVeOE?editors=0012">Fetch Inject on CodePen</a> using the latest version available on CDN.
Try [Fetch Inject on CodePen](https://codepen.io/jhabdas/pen/MpVeOE?editors=0012) using the latest version available on CDN.
Reference [Use Cases](#use-cases) to get a feel for what it can do.
Reference the [Use Cases](#use-cases) to get a feel for what it can do.

@@ -67,4 +74,4 @@ ## Installing

- Get it on NPM with `npm i fetch-inject`
- Bower with `bower install fetch-inject`
- Get it on NPM with `npm i -p fetch-inject`
- Bower with `bower i -p fetch-inject`
- CDN [using jsDelivr](http://www.jsdelivr.com/projects/fetch-inject)

@@ -261,9 +268,4 @@

All browsers with support for [Fetch](http://caniuse.com/#feat=fetch) and [Promises](http://caniuse.com/#search=promises).
All browsers with support for [Fetch](http://caniuse.com/#feat=fetch) and [Promises](http://caniuse.com/#search=promises). Because Fetch is a newer Web standard, we will help identify, open and track issues against browser implementations as they arise while specs are being finalized.
<blockquote>
Fetch will become available in Safari in the Safari 10.1 release that ships with macOS Sierra 10.12.4 and Safari on iOS 10.3.
<cite>Jon Davis</cite>,  Web Technologies Evangelist
</blockquote>
## Progressive Enhancement

@@ -326,2 +328,2 @@

[ISC](https://github.com/jhabdas/fetch-inject/blob/master/LICENSE)
[![ISC](https://img.shields.io/github/license/jhabdas/fetch-inject.svg?style=flat-square)](https://choosealicense.com/licenses/isc/ "ISC License")

@@ -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@licence ISC`
banner: `Fetch Inject v<%= pkg.version %>\nCopyright (c) <%= moment().format('YYYY') %> Josh Habdas\n@license ISC`
})

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

Sorry, the diff of this file is not supported yet

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