-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-ssr.js
33 lines (30 loc) · 1.14 KB
/
gatsby-ssr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import React from "react";
export function onRenderBody({ setHeadComponents }) {
setHeadComponents([
<script
dangerouslySetInnerHTML={{
__html: `
function loadScript(url) {
return new Promise((resolve, reject) => {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
script.onload = resolve;
script.onerror = reject;
document.body.appendChild(script);
});
}
async function loadScriptsSequentially() {
try {
await loadScript('/TweenMax.min.js');
await loadScript('/introduction.js');
} catch (error) {
console.error("Script loading failed:", error);
}
}
document.addEventListener('DOMContentLoaded', loadScriptsSequentially);
`
}}
/>
]);
}