New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

pre-image

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pre-image

A simple function to preload images in background idle time.

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

preImage

Preload images in background idle time.

A simple function to preload images in background idle time.

preImage(
    "/mock1.jpg", 
    "/mock2.png", 
    "https://mystiar.com/shino.png"
)

Queueing resources' requests download is important for optimization. Normally preload important images resources can be done with <link rel="preload> but what if there're a lot of requests?

Would you like to increase size on HTML file? like:

<link rel="preload" href="/mock1.jpg">
<link rel="preload" href="/mock2.png">
<link rel="preload" href="https://mystiar.com/shino.png>
...50 more resources to be preloaded.

Ouch! That's a lot of kB wasted!

Why even waste that spaces when you can just simply:

preImage(
    "/mock1.jpg", 
    "/mock2.png"
)

And can even be configured:

preImage(
    "/mock1.jpg", 
    "https://mystiar.com/shino.png"
, {
    delay: 1000,
    cors: true
})

Or wait until images's request is loaded

preImage('/mock1.jpg','/mock2.png').then(() => {
    console.log("All images are loaded!")
})

// or inside async function
await preImage('/mock1.jpg','/mock2.png')
console.log("All images are loaded!")

And the package size is just only 1kB!

Now you can just preload image without touching HTML. (Imagine you use React.js, Vue.js. You can just preload them directly!)

Keywords

pre-image

FAQs

Package last updated on 11 Nov 2019

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