(function(window) { function define_library() { // Create the library object and all its properties and methods. var vanillaZoom = {}; vanillaZoom.init = function(galleryId) { // Our library's logic goes here. } return vanillaZoom; } // Add the vanillaZoom object to global scope if its not already defined. if(typeof(vanillaZoom) === 'undefined') { window.vanillaZoom = define_library(); } else{ console.log("Library already defined."); } })(window);