sxg-subresource-iframe.html (833B)
1 <!DOCTYPE html> 2 <body> 3 <script> 4 (async () => { 5 const sxg_path = 'sxg/sxg-subresource.sxg'; 6 const scipt_sxg_path = 'sxg/sxg-subresource-script.sxg'; 7 const scipt_path = 'sxg-subresource-script.js'; 8 const wait_for_prefetch = new Promise((resolve) => { 9 new PerformanceObserver((list) => { 10 for (let e of list.getEntries()) { 11 if (e.name.endsWith(scipt_sxg_path)) { 12 resolve(); 13 } else if (e.name.endsWith(scipt_path)) { 14 window.parent.postMessage( 15 scipt_path + ' should not be prefetched', '*'); 16 } 17 } 18 }).observe({ entryTypes: ['resource'] }); 19 }); 20 21 const link = document.createElement('link'); 22 link.rel = 'prefetch'; 23 link.href = sxg_path; 24 document.body.appendChild(link); 25 await wait_for_prefetch; 26 location.href = sxg_path; 27 })() 28 </script> 29 </body>