The way I see it you have three options:
A. Do what you are already doing.
B. Perform the if test on the server-side, something like this:
<% if (IsTabVisible) { %>
// client-side code here, whatever you had inside the brackets
// of your original if statement
<% } %>
C. Make sure you generate 'true' and 'false' in lowercase so that it will work as client-side JavaScript, something like this:
if (<%= IsTabVisible ? "true" : "false" %>)
Which will appear to the client as:
if (true)
or
if (false)
Option A may look a bit funny but it works fine. Option C produces pretty client-side code that probably nobody will see. My preference is Option B.