Script Fails to run on netlify but works on github pages

My site is https://ytflix.netlify.app/Categories/Originals.html
It’s open-sourced at GitHub - n-ce/YTFLIX: A library of free official movies, series and documentaries available on YouTube.
One of the scripts “Search.js” i.e the Search function is not working but it used to, the same page works fine on github pages.

Welcome to the forums @n-ce

Possible this error is (part of) the cause
Screenshot 2021-08-31 15.39.01

Can you provide the link to the working GH Pages version?

1 Like

Here’s the GH pages link : https://n-ce.github.io/YTFLIX/Categories/Originals.html

It’s because of the null error:

Uncaught TypeError: Cannot set property 'onchange' of null
    at dc3fc184bb443aa81600fa216c8b50437e40f97c.js:12

The way it is packaged on GitHub they are different scripts so any exception on one won’t affect the others. But on Netlify it is all one file and the code to bind the keyup event is after the error so it never gets ran.

...
checkBox.onchange=function() { // <-- error here
  if (checkBox.checked==true) {
    meta("black");
  }else{
    meta("#333333");
    body.backgroundColor = "white";
  }
}
;
const search = document.querySelector("input");
search.onkeyup=function(){ // <- prevents this
...

Thanks guys, I was able to fix it!

1 Like