Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JS micro-optimization?
// readable and easily re-orderable
$(document).on('submit', '#foo', myCallback1);
$(document).on('submit', '#bar', myCallback2);
$(document).on('click', '.baz', myCallback3);
// performant
$(document).on('submit', '#foo', myCallback1)
.on('submit', '#bar', myCallback2)
.on('click', '.baz', myCallback3);
// also performant
$document = $(document);
$document.on('submit', '#foo', myCallback1);
$document.on('submit', '#bar', myCallback2);
$document.on('click', '.baz', myCallback3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.