first-input-delay
Advanced tools
Comparing version 0.1.2 to 0.1.3
# Changelog | ||
### 0.1.3 (2018-09-21) | ||
- Reduce the file size ([#11](https://github.com/GoogleChromeLabs/first-input-delay/pull/11)) | ||
### 0.1.2 (2018-08-09) | ||
- Filter out more erroneous values (#8) | ||
- Filter out more erroneous values ([#8](https://github.com/GoogleChromeLabs/first-input-delay/pull/8)) | ||
### 0.1.1 (2018-06-09) | ||
- Filter out erroneous values (#5) | ||
- Filter out erroneous values ([#5](https://github.com/GoogleChromeLabs/first-input-delay/pull/5)) | ||
@@ -11,0 +15,0 @@ ### 0.1.0 (2018-05-08) |
@@ -1,17 +0,1 @@ | ||
/* | ||
Copyright 2018 Google Inc. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
(function(){function g(a,b){d||(d=b,c=a,h=new Date,k(removeEventListener),l())}function l(){0<=c&&c<h-m&&(e.forEach(function(a){a(c,d)}),e=[])}function n(a,b){function c(){g(a,b);e()}function d(){e()}function e(){removeEventListener("pointerup",c,f);removeEventListener("pointercancel",d,f)}addEventListener("pointerup",c,f);addEventListener("pointercancel",d,f)}function p(a){if(a.cancelable){var b=(1E12<a.timeStamp?new Date:performance.now())-a.timeStamp;"pointerdown"==a.type?n(b,a):g(b,a)}}function k(a){["click", | ||
"mousedown","keydown","touchstart","pointerdown"].forEach(function(b){a(b,p,f)})}var d,c,h,e=[],f={passive:!0,capture:!0},m=new Date;k(addEventListener);self.perfMetrics=self.perfMetrics||{};self.perfMetrics.onFirstInputDelay=function(a){e.push(a);l()}})(); | ||
!function(n,e){var t,o,i,c=[],f={passive:!0,capture:!0},r=new Date,a="pointerup",u="pointercancel";function p(n,c){t||(t=c,o=n,i=new Date,w(e),s())}function s(){o>=0&&o<i-r&&(c.forEach(function(n){n(o,t)}),c=[])}function l(t){if(t.cancelable){var o=(t.timeStamp>1e12?new Date:performance.now())-t.timeStamp;"pointerdown"==t.type?function(t,o){function i(){p(t,o),r()}function c(){r()}function r(){e(a,i,f),e(u,c,f)}n(a,i,f),n(u,c,f)}(o,t):p(o,t)}}function w(n){["click","mousedown","keydown","touchstart","pointerdown"].forEach(function(e){n(e,l,f)})}w(n),self.perfMetrics=self.perfMetrics||{},self.perfMetrics.onFirstInputDelay=function(n){c.push(n),s()}}(addEventListener,removeEventListener); |
{ | ||
"name": "first-input-delay", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A JavaScript library for measuring the First Input Delay metric. See https://goo.gl/1AKcj5.", | ||
@@ -9,6 +9,8 @@ "main": "src/first-input-delay.js", | ||
"eslint": "^4.19.1", | ||
"eslint-config-google": "^0.9.1" | ||
"eslint-config-google": "^0.9.1", | ||
"terser": "^3.8.2" | ||
}, | ||
"scripts": { | ||
"test": "eslint src" | ||
"test": "eslint src", | ||
"build": "terser -c -m -o dist/first-input-delay.min.js src/first-input-delay.js" | ||
}, | ||
@@ -15,0 +17,0 @@ "repository": { |
@@ -16,3 +16,3 @@ /* | ||
(function() { | ||
(function(addEventListener, removeEventListener) { | ||
var firstInputEvent; | ||
@@ -26,2 +26,5 @@ var firstInputDelay; | ||
var pointerup = 'pointerup'; | ||
var pointercancel = 'pointercancel'; | ||
/** | ||
@@ -107,8 +110,8 @@ * Accepts a callback to be invoked once the first input delay and event | ||
function removePointerEventListeners() { | ||
removeEventListener('pointerup', onPointerUp, listenerOpts); | ||
removeEventListener('pointercancel', onPointerCancel, listenerOpts); | ||
removeEventListener(pointerup, onPointerUp, listenerOpts); | ||
removeEventListener(pointercancel, onPointerCancel, listenerOpts); | ||
} | ||
addEventListener('pointerup', onPointerUp, listenerOpts); | ||
addEventListener('pointercancel', onPointerCancel, listenerOpts); | ||
addEventListener(pointerup, onPointerUp, listenerOpts); | ||
addEventListener(pointercancel, onPointerCancel, listenerOpts); | ||
} | ||
@@ -141,6 +144,5 @@ | ||
onPointerDown(delay, evt); | ||
return; | ||
} else { | ||
recordFirstInputDelay(delay, evt); | ||
} | ||
recordFirstInputDelay(delay, evt); | ||
} | ||
@@ -174,2 +176,2 @@ } | ||
self['perfMetrics']['onFirstInputDelay'] = onFirstInputDelay; | ||
})(); | ||
})(addEventListener, removeEventListener); |
22830
3
153