Since this line defines a function, it shouldn't be inside the document ready $(function(){ ... }); block.  Inside the document ready block, the function definition isn't evaluated until the whole page has loaded.  That delays the execution of the page.  Only put code that depends on the HTML being there inside of the $() function.