is there any performance difference
Probably, since they are different functions. querySelector
at least needs to parse the selector before detecting that it's equal to getElementById
. And I doubt this optimisation takes place for the attribute selector at all, no one uses it. So I share your assumptions; and tests confirm them (thanks to @Silver_Clash).
Personally I do not like the second one, as it is more ambiguous and awful to use with dynamic id values. Explicitly using getElementById
is just more concise.