Lenis Smooth Scroll Working (only single page)

Hey guys jsut made Lenis Smooth Scroll work into my website. This is how:

In HEAD paste this:

<link rel="stylesheet" href="https://unpkg.com/lenis@1.1.20/dist/lenis.css">
<script src="https://unpkg.com/lenis@1.1.20/dist/lenis.min.js"></script>

Later copy and paste the code below in BEFORE BODY:

<script>
  window.addEventListener('load', function() {
    setTimeout(function() {
      if ('ontouchstart' in window || navigator.maxTouchPoints > 0) return;

      const scrollWrapper = document.querySelector('.content-scroll-wrapper') || document.querySelector('.overflow-on-vertical-view') || window;

      const lenis = new Lenis({
        wrapper: scrollWrapper === window ? window : scrollWrapper,
        content: scrollWrapper === window ? document.body : scrollWrapper.firstElementChild,
        duration: 1.2,
        easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
        smoothWheel: true,
        wheelMultiplier: 0.9
      });

      function raf(time) {
        lenis.raf(time);
        requestAnimationFrame(raf);
      }

      requestAnimationFrame(raf);
    }, 1000);
  });
</script>

It should work. I only made it work in single page websites. When in multi-pages it works fine in Main but when going into other sub-pages it stops working.