code: function(str, delim) {
              if (delim) return str.replace(new RegExp("^[\\s" + delim + "]+"),'').replace(new RegExp("[\\s" + delim + "]+$"), '');
              else return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
          }
docs: From http://blog.stevenlevithan.com/archives/faster-trim-javascript
  profiler shows this is much faster than the previous implementation in both IE and Firefox.
  
  @param {String} str The string to trim.
  @param {String} (Optional) delim The characters to remove from the start/end of the string.
  
  @type String
  @return A trimmed string.