Skip to content

Instantly share code, notes, and snippets.

@jeremyfelt
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyfelt/10760616 to your computer and use it in GitHub Desktop.
Save jeremyfelt/10760616 to your computer and use it in GitHub Desktop.
(function($){
$(document).ready(function(){});
}(jQuery));
/* Also worth noting - the above wraps functionality in an anonymous function, allowing you
to pass the jQuery object in to use as $. The use of .ready() means it will wait until the
entire DOM is loaded and the onReady event fires in the browser. This can sometimes happen
a couple seconds after the page has loaded into view.
If the script is loaded in the footer of the page, after the DOM is loaded, but not necessarily
before onReady fires, you may be able to do everything you need without .ready(), as below */
(function($)){
$('#my-selector').toggle(); // As long as #my-selector is in the DOM already
}(jQuery));
@natejacobson
Copy link

You rock. And seem to write documentation effortlessly. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment