Skip to content

Commit 4544e55

Browse files
committed
testing script preload
1 parent 235ad37 commit 4544e55

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

index.html

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<!-- End META-TAG Section -->
2323

2424
<!-- Begin LINK Section -->
25+
<link id="LcpLink" rel="preload" href="photos/quincy.acklen.webp" as="image" fetchpriority="high"/>
2526
<link href="images/orgchart_192x192.png" rel="apple-touch-icon" type="image/png"/>
2627
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
2728
<link rel="manifest" id="orgchart_manifest" crossorigin="use-credentials" href="manifest.json"/>
@@ -2069,26 +2070,21 @@
20692070
</style>
20702071
<!-- End STYLESHEET Section -->
20712072

2072-
<link id="LcpLink" rel="prefetch" href="" as="image" />
2073+
20732074
<!-- Begin JAVASCRIPT Section -->
20742075
<script>
2075-
const sDefaultPersonId = 'quincy.acklen';
2076-
function prefetchLargeImage()
2076+
let sDefaultPersonId = 'quincy.acklen';
2077+
function preloadLargeImage()
20772078
{
2078-
let oStartingPerson = null;
2079-
let sUrl = document.location.hash;
2080-
let sPersonId = sUrl.match( /person=([^&]*)/gi );
20812079
const link = document.getElementById("LcpLink");
2082-
if( sPersonId && sPersonId [ 0 ] )
2083-
{
2084-
sPersonId = sPersonId[ 0 ].replace( 'person=', '' );
2080+
const regex = /\/([^\/]+)\.[^\.]+$/;
2081+
const match = link.href.match(regex);
2082+
console.log(match[1])
2083+
if (match[1]) {
2084+
sDefaultPersonId = match[1];
20852085
}
2086-
else{
2087-
sPersonId = sDefaultPersonId;
2088-
}
2089-
link.href = `photos/${ sPersonId }.webp`
2090-
link.rel = "preload";
20912086
}
2087+
preloadLargeImage();
20922088
</script>
20932089

20942090
<script id="serviceworker_for_PWA">

0 commit comments

Comments
 (0)