Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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