Search code examples
githubgithub-pagessmooth-scrolling

Smooth scrolling doesn't work on github page


I have a problem with smooth scrolling, but only when website is opened with github page link... It's really weird, cause if I open it with live server, smooth scroll works... Does someone know what is it about? Everything is updated, code is the same, both on my computer and on github.

Link to the project: https://github.com/Beko44/M-M-Website . Github page where smooth scroll doesnt work - after clicking on smth in the menu (left upper corner) it kind of jumps instead of going smooth: https://beko44.github.io/M-M-Website/

Thanks!


Solution

  • If you open the browser console you could see an error:

    Mixed Content: The page at 'https://beko44.github.io/M-M-Website/' was loaded over HTTPS, but requested an insecure script 'http://code.jquery.com/jquery-3.4.1.min.js'. This request has been blocked; the content must be served over HTTPS.

    Since jQuery is not loaded because of this error your script for smooth scrolling will not work.

    To solve your problem just change the src from jQuery to be served by https in your index.html.

    <script
      src="https://code.jquery.com/jquery-3.4.1.min.js"
      integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
      crossorigin="anonymous">
    </script>