Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Small 'ua' function optimisation. http://jsperf.com/tinycon-js-ua

  • Loading branch information...
commit 6258c8ebdfd99d554e4e0673a4142cf7082175f5 1 parent ef308a3
darren authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 tinycon.js
View
11 tinycon.js
@@ -24,11 +24,14 @@
fallback: true
};
- var ua = function(browser){
+ var ua = (function (browser) {
var agent = navigator.userAgent.toLowerCase();
- return agent.indexOf(browser) !== -1;
- };
-
+ // New function has access to 'agent' via closure
+ return function (browser) {
+ return agent.indexOf(browser) !== -1;
+ };
+ }());
+
var browser = {
chrome: ua('chrome'),
webkit: ua('chrome') || ua('safari'),
Please sign in to comment.
Something went wrong with that request. Please try again.