nanobeacon

所属分类:GPT/ChatGPT
开发工具:JavaScript
文件大小:0KB
下载次数:0
上传日期:2022-12-27 09:16:32
上 传 者sh-1993
说明:  小型navigator.sendBeacon包装器
(Small navigator.sendBeacon wrapper)

文件列表:
.travis.yml (153, 2017-10-11)
LICENSE (1079, 2017-10-11)
example.js (217, 2017-10-11)
index.js (980, 2017-10-11)
package.json (471, 2017-10-11)

# nanobeacon [![stability][0]][1] [![npm version][2]][3] [![build status][4]][5] [![downloads][8]][9] [![js-standard-style][10]][11] Small `navigator.sendBeacon` wrapper. Sends an HTTP request with priority `lowest` to a remote host, and ensures it arrives without blocking page navigation. Useful for sending analytics data. Also a friendly reminder not to ever store people's IP addresses. Only store the minimum amount of data needed to inform decisions. Be kind, don't give analytics a bad name. ## Usage ```js var nanobeacon = require('nanobeacon') var url = 'http://jsfiddle.net?sendbeacon' var ok = nanobeacon(url, { hello: 'world' }) var msg = ok ? 'OK' : 'NOT OK' document.body.innerHTML = '

message status: ' + msg + '

' ``` ## API ### `ok = nanobeacon(url, [data])` Send a request with a payload to a remote host. If user has enabled Do Not Track (`window.navigator.doNotTrack`) then no beacon will be sent and nanobeacon will return `false`. ## See Also - [dom/navigator/sendBeacon](http://devdocs.io/dom/navigator/sendbeacon) ## License [MIT](https://tldrlegal.com/license/mit-license) [0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square [1]: https://nodejs.org/api/documentation.html#documentation_stability_index [2]: https://img.shields.io/npm/v/nanobeacon.svg?style=flat-square [3]: https://npmjs.org/package/nanobeacon [4]: https://img.shields.io/travis/yoshuawuyts/nanobeacon/master.svg?style=flat-square [5]: https://travis-ci.org/yoshuawuyts/nanobeacon [6]: https://img.shields.io/codecov/c/github/yoshuawuyts/nanobeacon/master.svg?style=flat-square [7]: https://codecov.io/github/yoshuawuyts/nanobeacon [8]: http://img.shields.io/npm/dm/nanobeacon.svg?style=flat-square [9]: https://npmjs.org/package/nanobeacon [10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square [11]: https://github.com/feross/standard

近期下载者

相关文件


收藏者