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

instant-prefetch

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

instant-prefetch

improves page loading for SPA apps

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

instant-prefetch

Extension of well known InstantPage library. All kudos for (☞゚∀゚)☞ Alexandre Dieulot

import { init } from 'instant-prefetch'

init(
  (element) => {
    // access to link url
    console.log(element.href)
    // We can also add data attributes to element and then retrive it here
    // For example:
    // <a data-instant-prefetch='{"url": "/women.html", "type": "category"}' >
    if ('instantDataPrefetch' in linkElement.dataset) {
      try {
        const data = JSON.parse(linkElement.dataset['instantDataPrefetch'])
        console.log(data) // do something
      } catch (err) {}
    }
  },
  // optional
  // same as global options added for https://instant.page/ to <body>
  {
    allowQueryString: false, // same as 'data-instant-allow-query-string' added to body in InstantPage https://instant.page/blacklist
    allowExternalLinks: false, // same as 'data-instant-allow-external-links' added to body in InstantPage https://instant.page/blacklist
    useWhitelist: false, // same as 'data-instant-allow-external-links' added to body in InstantPage https://instant.page/blacklist
    mousedownShortcut: false, // same as 'data-instant-mousedown-shortcut' added to body in InstantPage https://instant.page/intensity
    intensity = '', // 'data-instant-intensity' added to body in InstantPage https://instant.page/intensity
  }
)

// next call for `init` will only reload listeners and IntersectionObserver but list of triggered links will remain the same

See more information on the original website: https://instant.page/

License

MIT © gibkigonzo.

FAQs

Package last updated on 23 Oct 2020

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