Adding JS from HTML Template in Sveltekit project

Viewed 19

I have an HTML Template with CSS and JS. I wanted to import it in SvelteKit.

Adding HTML and CSS is pretty straightforward. When it comes to JS, there are problems.

As far as I have tested with the browser, The imported JS code works, but it fails to affect the DOM. Ex. console.log works, but adding bootstrap.js or slick.js do not work. Also, custom JS written is not loading. This means there is no issue with the directory.

This is how I have imported CSS and JS in Svelte.

<svelte:head>
    <link rel="stylesheet" href="/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/css/style.css" />
    <link rel="stylesheet" href="/css/responsive.css" />
    
    <script src="/js/jquery-3.6.0.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/owl.carousel.min.js"></script>
    <script src="/js/isotope.pkgd.min.js"></script>
    <script src="/js/slick.min.js"></script>
    <script src="/js/script.js"></script>
</svelte:head>

Is there another way to import external JS to Svelte files, a way where the JS will affect the DOM?

0 Answers
Related