We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(function () { /** * get first-meaningful-paint */ if (!window.performance || !window.performance.timing || !window.MutationObserver) { getfmpCallback(0); } window.count = 0; window.time = 0; var observeTime = 30000; var observedPoints = []; var innerHeight = window.innerHeight; var timing = window.performance.timing; var startTime = timing.navigationStart || timing.fetchStart; var observer = new window.MutationObserver(function(){ window.count++; var t = Date.now() - startTime; console.log(window.count); var start = Date.now(); var score = getDomMark(document, 1); console.log((Date.now() - start) + "ms"); console.log(t + " - fmp"); window.time = window.time + (Date.now() - start); console.log(window.time + " - total") observedPoints.push({ score: score, t: t }); }); observer.observe(document, { childList: true, subtree: true });; function getDomMark(dom, level) { var length = dom.children ? dom.children.length : 0; var sum = 0; var tagName = dom.tagName; if (tagName !== 'SCRIPT' && tagName !== 'STYLE' && tagName !== 'META' && tagName !== 'HEAD') { if (dom.getBoundingClientRect && dom.getBoundingClientRect().top < innerHeight) { sum += level * length; } if (length > 0) { var children = dom.children; for (var i = 0; i < length; i++) { sum += getDomMark(children[i], level + 1); } } } return sum; } setTimeout(function () { observer.disconnect(); var rates = []; for (var i = 1; i < observedPoints.length; i++) { if (observedPoints[i].t !== observedPoints[i - 1].t) { rates.push({ t: observedPoints[i].t, rate: observedPoints[i].score - observedPoints[i - 1].score }); } } rates.sort(function (a, b) { return b.rate - a.rate; }); if (rates.length > 0) { getfmpCallback(rates[0].t); } else { getfmpCallback(0); } }, observeTime); function getfmpCallback(fmp){ alert(fmp); window.FirstScreenTime = fmp; } })();
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: