🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@mightyplow/prefetcher

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mightyplow/prefetcher

library to simplify the usage of html prerender methods

latest
Source
npmnpm
Version
0.1.5
Version published
Maintainers
1
Created
Source

prefetcher

A small JavaScript library which can be used to asynchronously prefetch resources on a web page.

more info

browser support

Note: The Lazyload hint is not part of this library, yet.

Installation

npm i @mightyplow/prefetcher

Usage

ES6 module

The library can be imported via ES6 imports.

To get the whole object which holds all methods you can call

import prefetcher from '@mightyplow/prefetcher';

You can also import specific methods by calling

import { prefetch, preload, prerender, prefetchDns, preconnect } from '@mightyplow/prefetcher';

standalone

You can also use the library directly in your html document. All you have to do, is to load the prefetcher[.min].js file from the dist folder.

It will create a global object call prefetcher, which contains all the available methods.

methods

Following methods are available:

  • prefetch(src)
  • preload(src)
  • prerender(src)
  • prefetchDns(src)
  • preconnect(src)

All methods take the url of the resource which should be loaded. Internally they get stored in an array, so the prefetch request is only done once.

You can then call one of the methods to add the prefetch link tag to the head of the web page. After the resource has been loaded, the tag gets removed automatically.

prefetch('http://mydomain.tld/foobar');

Keywords

html

FAQs

Package last updated on 19 May 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