My Website is completely designed to without javascript. JS is added completely non intrusively.
Now I don't want to test the JS on all browsers (notably older IE versions), because they give no feedback for debugging, and it's just not worth my time.
So I'd simply like to disable JS on some browsers (or the opposite: allow it on the browsers I have tested it with).
Is there a way to do that? Or do I have to create a JS flag that I have to consult every time before I execute JS? (really don't want to do that)
I believe this would work: have this as the first
<script>
tagCwallenpoole's solution looks to me like it wouldn't work unless it's called on the DOM ready event or at least after the other script tags, at which point scripts would have already run.
If all your scripts are in one place, or at least not embedded all over the page, perhaps you should include them with JavaScript after checking the browser:
This is one scenario which illustrates why keeping your code D.R.Y. and all in one place is important.
For detecting browsers, check out quirksmode, but note the link to their Object detection page instead if that's more useful for your use case. Yepnope.js is useful for the latter, which is part of Modernizr.