{"action":"created","issue":{"url":"https://api.github.com/repos/substack/node-browserify/issues/1160","labels_url":"https://api.github.com/repos/substack/node-browserify/issues/1160/labels{/name}","comments_url":"https://api.github.com/repos/substack/node-browserify/issues/1160/comments","events_url":"https://api.github.com/repos/substack/node-browserify/issues/1160/events","html_url":"https://github.com/substack/node-browserify/issues/1160","id":60814180,"number":1160,"title":"Throttle/Debounce with Browserify","user":{"login":"realph","id":2334951,"avatar_url":"https://avatars.githubusercontent.com/u/2334951?v=3","gravatar_id":"","url":"https://api.github.com/users/realph","html_url":"https://github.com/realph","followers_url":"https://api.github.com/users/realph/followers","following_url":"https://api.github.com/users/realph/following{/other_user}","gists_url":"https://api.github.com/users/realph/gists{/gist_id}","starred_url":"https://api.github.com/users/realph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realph/subscriptions","organizations_url":"https://api.github.com/users/realph/orgs","repos_url":"https://api.github.com/users/realph/repos","events_url":"https://api.github.com/users/realph/events{/privacy}","received_events_url":"https://api.github.com/users/realph/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-03-12T12:53:34Z","updated_at":"2015-03-12T15:14:01Z","closed_at":null,"body":"I'm trying to get Ben Alman's [throttle/debounce script](https://github.com/cowboy/jquery-throttle-debounce/blob/master/jquery.ba-throttle-debounce.js) to play nice with Browserify, but I keep hitting a wall.\r\n\r\n    var $ = require('jquery');\r\n\r\n    // jQuery Throtttle/Debounce\r\n    (function(window,undefined){\r\n      ...\r\n    })(this);\r\n\r\n    function log( event ) {\r\n      console.log( $(window).scrollTop(), event.timeStamp );\r\n    };\r\n\r\n    $(window).scroll( $.throttle( 250, log ) );\r\n\r\nI'm requiring jQuery at the top of my file, but it keeps returning me a \"Uncaught TypeError: undefined is not a function\" error on this line:\r\n\r\n    $(window).scroll( $.throttle( 250, log ) );\r\n\r\nHowever, if I include both jQuery and my app.js file the traditional way with two `<script src=\"\">` tags, before the closing body tag, the code works.\r\n\r\nAm I doing something wrong here. Am I not understanding Browserify correctly?\r\n\r\nAny help is appreciated. Thanks in advance!"},"comment":{"url":"https://api.github.com/repos/substack/node-browserify/issues/comments/78499848","html_url":"https://github.com/substack/node-browserify/issues/1160#issuecomment-78499848","issue_url":"https://api.github.com/repos/substack/node-browserify/issues/1160","id":78499848,"user":{"login":"realph","id":2334951,"avatar_url":"https://avatars.githubusercontent.com/u/2334951?v=3","gravatar_id":"","url":"https://api.github.com/users/realph","html_url":"https://github.com/realph","followers_url":"https://api.github.com/users/realph/followers","following_url":"https://api.github.com/users/realph/following{/other_user}","gists_url":"https://api.github.com/users/realph/gists{/gist_id}","starred_url":"https://api.github.com/users/realph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realph/subscriptions","organizations_url":"https://api.github.com/users/realph/orgs","repos_url":"https://api.github.com/users/realph/repos","events_url":"https://api.github.com/users/realph/events{/privacy}","received_events_url":"https://api.github.com/users/realph/received_events","type":"User","site_admin":false},"created_at":"2015-03-12T15:14:01Z","updated_at":"2015-03-12T15:14:01Z","body":"How can I find that out? I'm just requiring jQuery from npm like I posted in the original question. Are you saying I'd need to set `window.jQuery` too? Are you suggesting something like this?\r\n\r\n    var $ = require('jquery');\r\n    window.$ = window.jQuery = require('jquery');"}}