The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents. The document can be further processed and the results of that processing can be incorporated back into the presented page.
If you want to manipulate a html page you need to wait until the DOM is completely loaded , before you can change things. Otherwise there is a chance that you will change something that isn't loaded yet.
There are two flavors you can use to find out if the DOM is ready
- the popular jQuery
- And the much discussed VanillaJs version
It just doesn't work with IE8! http://caniuse.com/#search=DOMContentLoaded