Skip to content

Instantly share code, notes, and snippets.

@shinypb
Created January 20, 2011 21:42
Show Gist options
  • Save shinypb/788739 to your computer and use it in GitHub Desktop.
Save shinypb/788739 to your computer and use it in GitHub Desktop.
Monkey-patch for jQuery to make it use native string trimming where available
// As of 1.4.2, jQuery doesn't make use of native string trimming when it's available
$.trim = (function (jQueryTrim) {
return ("test".trim && " test ".trim() === "test") ? function(str) { return str.trim(); } : jQueryTrim;
})($.trim);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment