From 832fe8d9dc9ec5fdd7a6578734349b8b2429093b Mon Sep 17 00:00:00 2001 From: darcyclarke Date: Wed, 13 Jun 2012 17:44:34 -0400 Subject: [PATCH] Micro optimizations. Moved compressor definition and settings extension outside loop --- jquery.fittext.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/jquery.fittext.js b/jquery.fittext.js index 1c4b29e..eebff96 100644 --- a/jquery.fittext.js +++ b/jquery.fittext.js @@ -12,19 +12,18 @@ (function( $ ){ $.fn.fitText = function( kompressor, options ) { - - var settings = { - 'minFontSize' : Number.NEGATIVE_INFINITY, - 'maxFontSize' : Number.POSITIVE_INFINITY - }; + + // Setup options + var compressor = kompressor || 1, + settings = $.extend({ + 'minFontSize' : Number.NEGATIVE_INFINITY, + 'maxFontSize' : Number.POSITIVE_INFINITY + }, options); return this.each(function(){ - var $this = $(this); // store the object - var compressor = kompressor || 1; // set the compressor - - if ( options ) { - $.extend( settings, options ); - } + + // Store the object + var $this = $(this); // Resizer() resizes items based on the object width divided by the compressor * 10 var resizer = function () { @@ -35,7 +34,7 @@ resizer(); // Call on resize. Opera debounces their resize by default. - $(window).resize(resizer); + $(window).on('resize', resizer); });