Skip to content

A lightweight, self-contained JavaScript module for real-time webpage update detection and user notification.

License

Notifications You must be signed in to change notification settings

afeiship/page-update-checker

Repository files navigation

page-update-checker

A lightweight, self-contained JavaScript module for real-time webpage update detection and user notification.

version license size download

Note

The url should be a public accessible url, no cacheable content.

installation

npm install @jswork/page-update-checker

usage

import PageUpdateChecker from '@jswork/page-update-checker';

const checker = PageUpdateChecker.run({
  url: 'https://afeiship.github.io/page-update-checker',
  interval: 1000 * 60 * 1, // 1 minutes
  onUpdateAvailable: () => {
    const confirmed = window.confirm('网页内容已经更新,你是否现在刷新?');
    if (confirmed) {
      window.location.reload();
    } else {
      this.ignore();
    }
  }
});

// trigger ingore events;
window.dispatchEvent(new CustomEvent('@:page-update-checker:ignore'));
// use nx
nx.rootDispatch('@:page-update-checker:ignore');

license

Code released under the MIT license.

About

A lightweight, self-contained JavaScript module for real-time webpage update detection and user notification.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published