I have simple code:
var aso=document.querySelector("body");
aso.style.background="yellow";
This is written in separate .js file. When you open the page, it is showing error:
simple.js:2 Uncaught TypeError: Cannot read property 'style' of null
at simple.js:2
But when I run this code in console window, it works fine, but showing error in separate JS file.