overlooker-element-timing
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "overlooker-element-timing", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "The package for measuring the element timing is more simple", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"build": "rollup -c", | ||
"watch": "rollup -c -w", | ||
"prepublish": "npm run build", | ||
"test": "jest" | ||
}, | ||
@@ -14,3 +17,12 @@ "repository": { | ||
"author": "Nikolay Ryabov", | ||
"license": "SEE LICENSE IN LICENSE" | ||
"license": "SEE LICENSE IN LICENSE", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@babel/core": "^7.9.0", | ||
"@babel/preset-env": "^7.9.0", | ||
"jest": "^25.3.0", | ||
"rollup": "^2.3.3", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-uglify": "^6.0.4" | ||
} | ||
} |
@@ -9,3 +9,35 @@ # overlooker-element-timing | ||
### Usage | ||
Adding the Overlooker Element Timing is a two-step process. | ||
First you need to add a snippet of code to the head of your document (before any other scripts run). | ||
This snippet creates a PerformanceObserver instance and starts observing element entry types. | ||
```js | ||
if (!window.oet) {window.oet = [];}if (PerformanceObserver) {new PerformanceObserver(function (l) {window.oet.push.apply(window.oet, l.getEntries());}).observe({ entryTypes: ['element'] });} | ||
``` | ||
*__Note:__ You can use something else instead of `oet`, but you should put this string in the OverlookerElementTiming constructor as the first argument.* | ||
Second step is to import the module in your application and subscribe to it | ||
```js | ||
import OverlookerElementTiming from 'overlooker-element-timing'; | ||
// you can put the name of the global variable that you used for store entries, in the first argument (default = 'oet') | ||
const overlookerElementTiming = new OverlookerElementTiming(); | ||
overlookerElementTiming.observe((entry) => { | ||
// entry object contains element timing data in readable form | ||
// use it according to your need | ||
}, true); // set to true, if you want to receive already handled entries; | ||
// for getting already handled entries | ||
overlookerElementTiming.getAll().forEach((entry) => { | ||
// handle | ||
}); | ||
``` | ||
If you want to use this script in embedded version (with script tag), you can put the ./dist/index.min.js anywhere and use it from global namespace | ||
```js | ||
window.oet.observe(() => { | ||
// ... | ||
}); | ||
``` |
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
20287
10
159
2
43
0
6