I refactored this code by making just a couple of very basic tweaks...
- move all logic out of the conditional and into variables
- removed unnecessary syntax cruft from
isProxyBrowser - give the variables descriptive names
- further break down the logic (e.g. group the checks for 'cutting the mustard' and 'being a proxy based browser')
- reversed the
isProxyBasedlogic so it becomesisNotProxyBased(this meant we didn't cluttermodernDevicewith extra syntax and made it as readable as possible) - use selected variables within the conditional
@robmiller in a typical file it would be yes. I normally have an Object literal with methods for each piece of unique functionality which lets me abide by SRP (the Single Responsibility Principle).
This example is actually from an inline chunk of code that's dumped out by a back-end system directly into an inline script file (eurgh!) so it's a bit like "polishing a turd", but moving that stuff into functions would be trivial (although I feel for the sake of an inline chunk of code that's a lot of extra cruft in comparison -> it all comes down to context)...