【An encountered Javascript Error】Uncaught TypeError: Cannot read property 'appendChild' of null

Since I renewed my computer, a editor system for javascript which I introduced on top of browser haven't worked very much so I checked my code by developer tool for a console of Javascript functioned by google Chrome , which then output following error.

"Uncaught TypeError: Cannot read property 'appendChild' of null"

It seemed it was not able to read the property for adding elements so I checked the position of "div tag" operating script, it indicated as "height:0px". It looked there was totally no territory for javascript operating.

It was really weird because CSS indicated "height: 100%" so I finally understood this error occurred in the case javascript is loaded faster than the load of body element is complete. Well it is quite natural when I think back now that value of null will be returned without a property of operating script.

The solution is moving the script just right before the end of the body tag.

I made a basic error. I took a note just in case I make this kind error again.