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

async-preloader

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-preloader

Assets preloader using ES2017 async/await and fetch.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

async-preloader Build Status styled with prettier

Assets preloader using ES2017 async/await and fetch.

Install

$ npm install --save async-preloader

Usage

import AsyncPreloader from "async-preloader";

const pItems = AsyncPreloader.loadItems([
  { src: "/static/default" }, // A file without extension or loader specified uses `Response.text()`
  { id: "myTextFile", src: "/static/text.txt" },
  { id: "myJsonFile", src: "/static/json.json" },
  { id: "myImageFile", src: "/static/image.jpg" },
  { id: "myVideoFile", src: "/static/video.mp4" },
  { id: "myAudioFile", src: "/static/audio.mp3" },
  { id: "myXmlFile", src: "/static/xml.xml" },
  { id: "mySvgFile", src: "/static/xml.svg" },
  { id: "myHtmlFile", src: "/static/xml.html" },
  { loader: "Font", src: "Open Sans" } // src is the font name here https://github.com/bramstein/fontfaceobserver
]);

pItems
  .then(items => {
    console.log("All items loaded", items);

    const element = AsyncPreloader.items.get("myVideoFile");
    document.body.appendChild(element);
  })
  .catch(error => console.error("Error loading items", error));

License

MIT © Damien Seguin

Keywords

FAQs

Package last updated on 08 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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