From b4ad3d8fdcfda36923e12dd782d9002e73188631 Mon Sep 17 00:00:00 2001 From: Saint Clair Date: Fri, 30 Aug 2013 14:29:18 -0300 Subject: [PATCH 1/2] Improving the Performance of iterations --- jquery.lettering.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jquery.lettering.js b/jquery.lettering.js index 8a693c8..539d3a0 100644 --- a/jquery.lettering.js +++ b/jquery.lettering.js @@ -13,10 +13,11 @@ (function($){ function injector(t, splitter, klass, after) { var a = t.text().split(splitter), inject = ''; - if (a.length) { - $(a).each(function(i, item) { - inject += ''+item+''+after; - }); + var len = a.length; + if (len > 0) { + for (var i = 0; i < len; i++) { + inject += ''+a[i]+''+after; + } t.empty().append(inject); } } From 638867a230cfe69cec0169f87eeb459e792b92d9 Mon Sep 17 00:00:00 2001 From: Saint Clair Date: Fri, 30 Aug 2013 14:35:15 -0300 Subject: [PATCH 2/2] Including min file --- jquery.lettering.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 jquery.lettering.min.js diff --git a/jquery.lettering.min.js b/jquery.lettering.min.js new file mode 100644 index 0000000..af0d181 --- /dev/null +++ b/jquery.lettering.min.js @@ -0,0 +1 @@ +(function(b){function c(j,k,e,l){var f=j.text().split(k),h="";var d=f.length;if(d>0){for(var g=0;g'+f[g]+""+l}j.empty().append(h)}}var a={init:function(){return this.each(function(){c(b(this),"","char","")})},words:function(){return this.each(function(){c(b(this)," ","word"," ")})},lines:function(){return this.each(function(){var d="eefec303079ad17405c889e092e105b0";c(b(this).children("br").replaceWith(d).end(),d,"line","")})}};b.fn.lettering=function(d){if(d&&a[d]){return a[d].apply(this,[].slice.call(arguments,1))}else{if(d==="letters"||!d){return a.init.apply(this,[].slice.call(arguments,0))}}b.error("Method "+d+" does not exist on jQuery.lettering");return this}})(jQuery); \ No newline at end of file