javascript document.querySelector null = error / breaks other javascript [duplicate]

my javascript =

document.querySelector('#plus').addEventListener('click', () =>
tlshowhide.reversed() ? tlshowhide.play() : tlshowhide.reverse() );

Where my page has the #plus element this works fine but if the page does not have the #plus element then the console shows an error

 document.querySelector(...) is null

and other unrelated javascript breaks.

So is it expected that document.querySelector being null is an error that breaks other javascript, and if so how can I rewrite my javascript to say “if the element X is found on the page do Y, and if element X is not found on the page then don’t worry about it, just move on”?