mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
FIX: Prefetch
This commit is contained in:
parent
85f9c08cb1
commit
244a0c8629
@ -253,16 +253,17 @@ class DeferredRequirements implements TemplateGlobalProvider
|
||||
|
||||
$html .= '<link rel="preload" as="fetch" href="'.$preloadPath.'" />'
|
||||
.'<script>'
|
||||
.'window.addEventListener("load-ready",() =>{'
|
||||
.'window.dispatchEvent(new Event("prefetch-loaded"));console.log("Prefetched before js ready")'
|
||||
.'});'
|
||||
.'try{'
|
||||
."fetch('".$preloadPath."', {method:'GET',credentials:'include',mode:'no-cors'})"
|
||||
.'.then((r)=>{return r.json()})'
|
||||
.'.then((d)=>{'
|
||||
.'window.preloadedData = d;'
|
||||
.'window.dispatchEvent(new Event("prefetch-loaded"));'
|
||||
.'console.log("Prefetch is loaded")'
|
||||
.'console.log("Prefetch is loaded");'
|
||||
.'window.addEventListener("load-ready",() =>{'
|
||||
.'window.dispatchEvent(new Event("prefetch-loaded"));'
|
||||
.'console.log("Prefetched before js ready")'
|
||||
.'});'
|
||||
.'})'
|
||||
.'.catch((e) => {'
|
||||
.'window.dispatchEvent(new Event("prefetch-loaded"));'
|
||||
|
Loading…
Reference in New Issue
Block a user