I do not want start the slippery slope of benchmarking everything, BUT, this is _ssssslowwww_

Why not use a for based algo?

function countSpaces (str) {
  for (var i=0; i < str.length; i++){
    if (str[i] !== " ") {
      return i;
    }
  }
  return 0;
}

Here there is a benchmark for this code:
http://jsperf.com/whitespace-counting-algorithms