In the interests of having all my code snippets in a single location, here’s an empty JS file in case I need to cut and paste it into an existing theme or plugin. It uses the module pattern, meaning that all of the custom code is encapsulated in a single JS namespace. In this case Generico, as in my Genesis starter theme.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var generico = (function ($) { | |
'use strict'; | |
/** | |
* Empty placeholder function. | |
* | |
* @since 1.0.0 | |
*/ | |
var functionName = function () { | |
// Empty function, do all the things. | |
}, | |
/** | |
* Fire events on document ready, and bind other events. | |
* | |
* @since 1.0.0 | |
*/ | |
ready = function () { | |
functionName(); | |
// Examples binding to events. | |
$(window).on('resize.generico', functionName); | |
$(window).on('scroll.generico resize.generico', functionName); | |
}; | |
// Only expose the ready function to the world | |
return { | |
ready: ready | |
}; | |
})(jQuery); | |
jQuery(generico.ready); |
Leave a Reply