You can do something like this, where you check how often your event is fired with an interval of 1 second and whether it processes it. Sample code, rough outline of what I thought (no gaurantee (like this spelling)).
function process_event() { var curr = new Date().getTime(); if ((curr - timeObj.last) < 1000) { //One Second if (timeObj.counter > 25) { for (var x=0;x<timeObj.times;x++) { if ((curr - timeObj.times[x]) >= 1000) { timeObj.times.splice(x, 1); timeObj.counter -= 1; } } } else { timeObj.counter += 1; timeObj.times[timeObj.times.length()-1] = curr; } } else { timeObj.counter = 0; timeObj.times = []; } if (timeObj.counter > 25) { return False } else { return True } }
source share