You should also wrap your code into a namespace with IIFE to avoid global conflict and immediate execution. i.e. (function (token, undefined) { token.init = function () { var self = this; //add event handler $('#friend').on('keyup', function (event) { //test data to make sure its usable self.testData( $(this) , event ); }); }; }(window.token = window.token || {}));