Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* Page-side instrumentációs script — `page.addInitScript` input.
*
* **PURE JavaScript** (NEM TypeScript) — a browser direktül futtatja, NEM
* megy át tsc-n. Self-contained, NEM importál külső libet.
*
* Az eredményeket a `window.__dye2e_cwv_events__` tömbbe rakja.
* Lefedi: LCP, CLS, FCP, TTFB. INP Wave-3.5 — interakció-script kell.
*/
export const DYE2E_WEB_VITALS_PAGE_SCRIPT: string = `
(function () {
var w = window;
if (w.__dye2e_cwv_events__) { return; }
w.__dye2e_cwv_events__ = [];
var events = w.__dye2e_cwv_events__;
function pushEvent(metric, value, attribution) {
events.push({ metric: metric, value: value, attribution: attribution, t: Date.now() });
}
try {
var navEntries = performance.getEntriesByType('navigation');
if (navEntries.length > 0) {
pushEvent('ttfb', Math.max(0, navEntries[0].responseStart));
}
} catch (e) {}
try {
var po1 = new PerformanceObserver(function (list) {
var entries = list.getEntries();
for (var i = 0; i < entries.length; i++) {
if (entries[i].name === 'first-contentful-paint') {
pushEvent('fcp', entries[i].startTime);
}
}
});
po1.observe({ type: 'paint', buffered: true });
} catch (e) {}
try {
var lastLcp = 0;
var lastLcpAttr = null;
var po2 = new PerformanceObserver(function (list) {
var entries = list.getEntries();
for (var i = 0; i < entries.length; i++) {
var e2 = entries[i];
lastLcp = e2.startTime;
lastLcpAttr = { element: e2.element ? (e2.element.tagName + (e2.element.id ? '#' + e2.element.id : '')) : null };
}
});
po2.observe({ type: 'largest-contentful-paint', buffered: true });
var clsValue = 0;
var clsSources = [];
var po3 = new PerformanceObserver(function (list) {
var entries = list.getEntries();
for (var i = 0; i < entries.length; i++) {
var e3 = entries[i];
if (!e3.hadRecentInput) {
clsValue += e3.value;
if (e3.sources && e3.sources.length > 0) {
for (var s = 0; s < e3.sources.length; s++) {
var src = e3.sources[s];
clsSources.push({ node: src.node ? (src.node.tagName || 'unknown') : null });
}
}
}
}
});
po3.observe({ type: 'layout-shift', buffered: true });
var snapshot = function () {
pushEvent('lcp', lastLcp, lastLcpAttr);
pushEvent('cls', clsValue, { sources: clsSources });
};
addEventListener('pagehide', snapshot, true);
addEventListener('visibilitychange', function () {
if (document.visibilityState === 'hidden') { snapshot(); }
}, true);
w.__dye2e_cwv_snapshot__ = snapshot;
} catch (e) {}
})();
`.trim();
|