Skip to content

Instantly share code, notes, and snippets.

@pokk
Created April 21, 2017 09:44
Show Gist options
  • Save pokk/6898c4f6f996a95069a828a604b5d0ba to your computer and use it in GitHub Desktop.
Save pokk/6898c4f6f996a95069a828a604b5d0ba to your computer and use it in GitHub Desktop.
Add the html loading ready in Javascript

Introduction

Add the html loading ready in Javascript.

Javascript

There is a standards based replacement,DOMContentLoaded that is supported by over 98% of browsers, though not IE8.

document.addEventListener("DOMContentLoaded", function(event) { 
    // Do something.
});

This equals the below.

$(document).ready({
    // Do something.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment