In the following JavaScript code sample:
var myButton = $('#myButton');
myButton.click(function (event) {
/* stuff... */
event.preventDefault();
});
What are the advantages and disadvantages of default-preventing the action at the beginning or the end of the function? - supposing the case of unconditionally wanting to prevent it in the end. Is there any technical reason to choose one way?
Surfing the internet I've found only one reference -dead blog, sorry for the Google Cache link-, and points that preventing the default action at the beginning will avoid the action happening in case the js function crashes.
NOTE: I've used jQuery in my example just for familiarity, the question is not about jQuery, the answer for the classical event handling mode will be the same.