Snippets

Detect when the document is ready:

document.addEventListener('DOMContentLoaded', function () {
    // Something
});

Reference