Skip to content

Instantly share code, notes, and snippets.

@iamdustan
Last active December 15, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamdustan/b15d32c6780ef3170a1b to your computer and use it in GitHub Desktop.
Save iamdustan/b15d32c6780ef3170a1b to your computer and use it in GitHub Desktop.
function highlyExpensiveFunction(elementNode) {
$(elementNode).css({
'position': 'fixed'
});
offsetTop = $(elementNode).offset().top;
offsetLeft = $(elementNode).offset().left;
anotherExpensiveFunction(elementNode, offsetTop, offsetLeft);
return elementNode;
}
// Let’s finish setting up this short example by calling this with some setup code.
function initExpensiveWork(elementNode) {
$(elementNode).on('scroll', function () {
highlyExpensiveFunction(elementNode);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment