The fastest solution is using the regex prototype function test() and looking for any character that is not a space or a line break \S
:
if (/\S/.test(str))
{
// found something other than a space or a line break
}
In case that you have a super long string, it can make a significant difference.