Animations

API

Arrays

Async

Basics

Challenges

Classes

Console

Dates

Debugging

DOM Elements

DOM Methods

DOM Navigation

DOM Properties

Event Listeners

Flow Control

Forms

Functions

Global Functions

JSON

Keywords

Libraries (3rd party)

Math

Modules

Objects

Snippets

String

Types

Widgets

Window Object

JavaScript - Defer

Sometimes you will have an issue where the page with throw an error because it is trying reference an element in a script file which has not been yet written to the page. Wrapping the code in a jQuery document ready function is one approach but if you don’t have jQuery in your project, you can tag the script file with a defer attribute:


<script src="javascripts/libraries/knockout-3.4.2.js"></script>
<script src="javascripts/app.js" defer="defer"></script>

This tells the browser not to load this script until the page has finished loading.