Created
September 14, 2013 13:11
-
-
Save navneetkumar/6561927 to your computer and use it in GitHub Desktop.
Code optimizaton
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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