function getTimeToInteractive() { const domInteractive = window.performance.timing.domInteractive; const requestStart = window.performance.timing.requestStart; return domInteractive - requestStart; } /* * returns: [ * { * name: 'haha.js', * duration: 12313, * transferSize: [bytes || 0 if served from cache] * }] */ function getResourceEntries() { return window.performance.getEntriesByType('resource') || []; } /* * Browser support: full * Success rate: > 95% * Can prefetch HTML: no */ function prefetchResource(resourceURL) { const xhrRequest = new XMLHttpRequest(); xhrRequest.open('GET', resourceURL, true); xhrRequest.send(); }