Improvements to the tab JS + conditional logic

Signed-off-by: Elliot Condon <e@elliotcondon.com>