Looks like a race condition where the tsParticles.load() is running before the js has finished loading.
Since you’re already in the <head> element, you can probably just pull out the code for making a script tag for tsParticles, and just make it an actual script tag so that it loads with the page instead of after page load finishes.
If you need to keep the script load in the JS, you can run the code on the load event.
const script = document.createElement('script');
script.addEventListener("load", () => {
console.log("called", tsParticles);
initTsParticles();
})
script.src = "https://cdn.jsdelivr.net/npm/@tsparticles/preset-links@3.0.2/tsparticles.preset.links.bundle.min.js";
document.head.appendChild(script);
function initTsParticles() {
tsParticles.load({
...
});
}