PageSourceSearch

https://www.pymnts.com/wp-content/plugins/pymnts-analytics/js/search-submit.js?ver=1a16c85fa72c

js pymnts.com collected 2026-10-01 06:42:09 UTC 1,928 bytes, 72 lines download raw bytes

1/**
2 * Holds a site search submit until the tap's next frame has painted, so
3 * gtag.js's form tracking, which handles every submit synchronously, runs
4 * outside the interaction.
5 */
6
7( () => {
8	// Without requestSubmit() a replay could not reach the submit listeners, so
9	// the browser submits as it would without this script.
10	if ( typeof HTMLFormElement.prototype.requestSubmit !== 'function' ) {
11		return;
12	}
13
14	// A backstop in case no frame comes.
15	const FALLBACK_MS = 500;
16
17	const pending = new WeakSet();
18	let replaying = null;
19
20	const isSearchForm = form => form instanceof HTMLFormElement && 'get' === form.method && !! form.querySelector( 'input[name="s"]' );
21
22	// requestSubmit() dispatches submit again, reaching every listener once.
23	// form.submit() would skip them, and gtag.js wraps it.
24	const replay = ( form, submitter ) => {
25		pending.delete( form );
26		replaying = form;
27
28		try {
29			form.requestSubmit( submitter && submitter.form === form ? submitter : null );
30		} finally {
31			replaying = null;
32		}
33	};
34
35	// Capture on window runs before gtag.js's listener on document. A hidden
36	// page paints nothing, so there is nothing to wait for.
37	window.addEventListener(
38		'submit',
39		ev => {
40			const form = ev.target;
41
42			if ( form === replaying || ! isSearchForm( form ) || 'hidden' === document.visibilityState ) {
43				return;
44			}
45
46			ev.preventDefault();
47			ev.stopImmediatePropagation();
48
49			if ( pending.has( form ) ) {
50				return;
51			}
52
53			pending.add( form );
54
55			let done = false;
56			const run = () => {
57				if ( ! done ) {
58					done = true;
59					document.removeEventListener( 'visibilitychange', run );
60					replay( form, ev.submitter );
61				}
62			};
63
64			requestAnimationFrame( () => setTimeout( run, 0 ) );
65			setTimeout( run, FALLBACK_MS );
66
67			// Frames stop once the page is hidden, and iOS suspends timers with them.
68			document.addEventListener( 'visibilitychange', run );
69		},
70		true
71	);
72} )();

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.