Skip to content

Instantly share code, notes, and snippets.

@navneetkumar
Created September 14, 2013 13:11
Show Gist options
  • Save navneetkumar/6561927 to your computer and use it in GitHub Desktop.
Save navneetkumar/6561927 to your computer and use it in GitHub Desktop.
Code optimizaton
//Use underscore library(http://underscorejs.org) for sample codes below
//Memoize a long running function
var optimized_function = _.memoize(function(n) {
//Code for a long running task
});
//Function throttling to avoid multiple execution
var wait_time = 100 //in ms
var throttled_function = _.throttle(updatePosition, wait_time);
$(window).scroll(throttled_function);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment