jQuery performance optimisation

... as reported by the PHPStorm static code analysis. Probably does
not have a measurable effect but makes the code a bit cleaner (less
duplicate code).

Change-Id: Iece509805b1f56cee83ade7b00e8990a87407fdc
Merge "jQuery performance optimisation"