Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created October 17, 2016 15:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tommcfarlin/83f079ed5d3a1bdd06cd74382a5e2a51 to your computer and use it in GitHub Desktop.
Save tommcfarlin/83f079ed5d3a1bdd06cd74382a5e2a51 to your computer and use it in GitHub Desktop.
[WordPress] IIFE For JavaScript in WordPress
(function( $ ) {
'use strict';
$(function() {
// Code to fire when the DOM is ready.
});
})( jQuery ); // This invokes the function above and allows us to use '$' in place of 'jQuery' in our code.
(function( $ ) {
'use strict';
/**
* This function can be referenced inside of this particular file but no where else.
*/
var example_function = function() {
// Do some neat work like write random data to the console.
};
$(function() {
// Code to fire when the DOM is ready. For example...
example_function();
});
})( jQuery ); // This invokes the function above and allows us to use '$' in place of 'jQuery' in our code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment