1.2.44 • Published 6 years ago

page-preloader v1.2.44

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

A simple page preloader using a dedicated web worker.

:cloud: Installation

npm install page-preloader

:clipboard: Example

import { PagePreloader } from 'page-preloader';
// let { PagePreloader } = require('page-preloader')

// use default options
PagePreloader.init()

PagePreloader.query("https://www.example.com", "/api/products?page=1&category=baz")

window.__preloadedData
// Preloaded data are available inside this global variable
// You should negotiate this object before requesting raw data for a new page

:memo: Documentation

PagePreloader.init(options)

Initializes internal flow of code.

Usage:

PagePreloader.init({
    debug: false, // default
    // Turns debug mode on or off.
    
    preloadKey: 'uri', // default
    // Saves preloaded data for a certain page under this key.
    // - 'uri' - saves data using URI string. Example: { '/api/products?page=1': ..data.. }
    // - 'page' - saves data using page number. Example: { 1: ..data.. }
    
    preloadDelay: 2000, // default
    // Determines delay in [ms] after which to start preloading.
    
    cacheDuration: 60000, // default
    // Determines cache duration in [ms] for preloaded data
    // Once the duration period expires, data are requested again.
    
    maxInactivityTicks: 20, // default
    // Determines ticks for inactivity period.
    // One tick expires whenever preloaded page history remains unchanged following cache expiration.
})

Params

  • object options: Configuration object.

Return

  • void

PagePreloader.query(origin, endPoint)

Queries requested resource.

Usage:

PagePreloader.query(origin, endPoint)

Params

  • string origin: Requested resource base URL (eg. https://www.example.com).
  • string endPoint: Requested resource end-point (eg. /api/products?page=1&category=baz).

Return

  • void

window.__preloadedData

Container for preloaded data.

Usage:

window.__preloadedData
// Preloaded data are available inside this global variable
// You should negotiate this object before requesting raw data for a new page

MIT

1.2.44

6 years ago

1.2.43

6 years ago

1.2.42

6 years ago

1.2.41

6 years ago

1.2.4

6 years ago

1.2.31

6 years ago

1.2.3

6 years ago

1.2.21

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago