1/** 2 * Cocoon WordPress Theme 3 * @author: yhira 4 * @author: technote-space 5 * @link: https://wp-cocoon.com/ 6 * @license: http://www.gnu.org/licenses/gpl-2.0.html GPL v2 or later 7 * @descriptionãPassive Event Listener ã使ç¨ãã¦ãµã¤ãã§ã®ã¹ã¯ãã¼ã« ããã©ã¼ãã³ã¹ãåä¸ããããã¸ã®å¯¾å¿ (https://developers.google.com/web/tools/lighthouse/audits/passive-event-listeners?hl=ja) 8 */ 9(function () { 10 // https://stackoverflow.com/questions/14439903/how-can-i-detect-device-touch-support-in-javascript 11 const isTouchSupported = 'ontouchstart' in window || 12 window.DocumentTouch && document instanceof window.DocumentTouch || 13 navigator.maxTouchPoints > 0 || 14 window.navigator.msMaxTouchPoints > 0; 15 16 if (isTouchSupported) { 17 // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection 18 let supportsPassive = false; 19 try { 20 let opts = Object.defineProperty({}, 'passive', { 21 get: function () { 22 supportsPassive = true; 23 } 24 }); 25 window.addEventListener("testPassive", null, opts); 26 window.removeEventListener("testPassive", null, opts); 27 } catch (e) { 28 } 29 30 if (supportsPassive) { 31 // https://stackoverflow.com/questions/36675693/eventtarget-interface-in-safari 32 const target = window.EventTarget || Element; 33 const originalAddEventListener = target.prototype.addEventListener; 34 target.prototype.addEventListener = function (type, listener, options) { 35 if ('wheel' === type || 'mousewheel' === type || 'touchstart' === type || 'touchmove' === type) { 36 options = options || {}; 37 options.passive = true; 38 } 39 originalAddEventListener.call(this, type, listener, options); 40 }; 41 } 42 } 43})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.