Skip to content

Instantly share code, notes, and snippets.

@isotrope
Created May 18, 2015 15:12
Show Gist options
  • Save isotrope/09a0858ec771cf2abbdb to your computer and use it in GitHub Desktop.
Save isotrope/09a0858ec771cf2abbdb to your computer and use it in GitHub Desktop.
Basic jQuery/JavaScript starter file to re-use. (Also, WP-jQuery-version-safe)
;
MyObject = typeof MyObject === 'undefined' ? {} : MyObject;
(function ($) {
$.noConflict();
MyObject.module1 = {
init : function () {
var _this = MyObject.module1;
_this.$mainContainer = $('.main-container');
if (_this.$mainContainer.length > 0) {
_this.bindEvents();
}
},
bindEvents: function () {
var _this = MyObject.module1;
}
};
// Put all the functionality that needs to run immediately here
$(document).ready(function () {
// Put all the functionality that needs to run on doc.ready here
MyObject.module1.init();
});
$(window).load(function () {
// Put all the functionality that needs to run on window.load here
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment