PageSourceSearch

https://11182.work/wp-content/themes/cocoon-master/js/set-event-passive.js?ver=5.0.22&fver=20200518104831

js 11182.work collected 2026-10-09 04:09:08 UTC 1,955 bytes, 43 lines download raw bytes

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.