is it better to do this (regarding performance, not readability…):
$('a.updateCartButton').click(function() {
$('form[name=updateCartForm]').attr('action', $(this).attr('href') + '#' + $('img[id^=iconUpdateArticle]').attr('id')).submit();
return false;
});
or this:
$('a.updateCartButton').click(function() {
var actionHref = $(this).attr('href');
var buttonId = $('img[id^=iconUpdateArticle]').attr('id');
$('form[name="updateCartForm"]').attr('action', actionHref + '#' +buttonId).submit();
return false;
});
Maybe someone could also explain to me how I can write a test case for something like this in jQuery Tester? Then I don’t have to ask questions like this in the future… 😉
Thanks!
Either one is fine, you’re talking about the performance of variable assignment, quite possibly the fastest feature in any language. The difference between:
versus:
Should be close to nil for all modern day languages.