modulepreload-iframe.html (593B)
1 <!DOCTYPE html> 2 <body> 3 <script> 4 const m = new URL('module1.js', location.href).toString(); 5 const observer = new PerformanceObserver(l => { 6 const entries = l.getEntriesByName(m); 7 if (entries.length === 1) { 8 import(m).then(() => { 9 observer.disconnect(); 10 const all = performance.getEntriesByName(m); 11 window.parent.postMessage(all.length, '*'); 12 }); 13 } 14 }); 15 16 observer.observe({type: 'resource', buffered: true}); 17 18 19 </script> 20 </body>