I think this is another boot order issue.
Your script runs immediately after loading it. If the page element that he is trying to hide is not loading in the DOM while the script is running, then do not hide anything. I believe that registered scripts get to the top of the page, in front of the HTML content, so this will always happen.
For this to work, you must put it in the boot event listener. See: Running javascript code when loading a page without using the onload tag
However, since you are trying to hide a page element without any conditions, you would probably be just as happy if this page element was disabled on the server side by adding a class to the element that your CSS does hide or manipulate your style / visibility directly from server code.
If it is assumed that there is some condition about whether the Div is visible or not, then doing it all on client javascript is probably better, so you do not need to make a trip on the server just to control visibility.
source share