JavaScript and jQuery Snippets
jQuery
$(function() {
// Handler for .ready() called.
// Shorthand version
});
(function ($) {
// Immediately Invoked Function Expression
// passing jQuery to avoid conflict
})(jQuery);
;(function ( $, window, document, undefined ) {
// Immediately Invoked Function Expression
// passing parameters for jQuery Plugins
// https://github.com/jquery-boilerplate/jquery-boilerplate/blob/master/src/jquery.boilerplate.js
})( jQuery, window, document );
JavaScript
(function(){
// Immediately Invoked Function Expression
// Vanilla JavaScript equivalent
}());
// Dynamically load JavaScript files
function loadScript(source, callback) {
if (!source) return;
var el = document.createElement('script');
el.type = 'text/javascript';
el.src = source;
el.onload = callback || console.log('Loaded');
document.body.appendChild(el);
}Written by Gianluca Esposito
Related protips
2 Responses
Hi, I'm a beginner in JavaScript but i want to launch a web up and i need help. Can JavaScript collect data input from a user and send to my email address automatically in a word format if so can you show me???
over 1 year ago
·
Hi, I'm a beginner in JavaScript but i want to launch a web up and i need help. Can JavaScript collect data input from a user and send to my email address automatically in a word format if so can you show me???
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#