From 6354b712fcc8bef70592b1b06817507026c2de9c Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 6 Dec 2013 11:00:14 -0500 Subject: [PATCH] Limit jQuery calls in ui.left_userlist_get_new_heights(). Calling $('#foo') is expensive, so if you need it twice, you should store it in a variable. I did this for stream_filters and user_presences, and added the expectOne() call for them as well. (imported from commit 69e689e28b1248a93ef426a89c14033d2fb36104) --- static/js/ui.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/static/js/ui.js b/static/js/ui.js index 67dc340809..34b48d35a6 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -419,8 +419,11 @@ function left_userlist_get_new_heights() { var invite_user_link_height = $("#invite-user-link").outerHeight(true) || 0; var share_the_love_height = $("#share-the-love").is(":visible") ? $("#share-the-love").outerHeight(true) : 0; - var stream_filters_real_height = $("#stream_filters").prop("scrollHeight"); - var user_list_real_height = $("#user_presences").prop("scrollHeight"); + var stream_filters = $('#stream_filters').expectOne(); + var user_presences = $('#user_presences').expectOne(); + + var stream_filters_real_height = stream_filters.prop("scrollHeight"); + var user_list_real_height = user_presences.prop("scrollHeight"); res.bottom_whitespace_height = viewport_height * 0.4; @@ -435,9 +438,9 @@ function left_userlist_get_new_heights() { - $("#global_filters").outerHeight(true) - $("#streams_header").outerHeight(true) - $("#userlist-header").outerHeight(true) - - parseInt($("#stream_filters").css("marginBottom"),10) - - parseInt($("#user_presences").css("marginTop"), 10) - - parseInt($("#user_presences").css("marginBottom"), 10) + - parseInt(stream_filters.css("marginBottom"),10) + - parseInt(user_presences.css("marginTop"), 10) + - parseInt(user_presences.css("marginBottom"), 10) - invite_user_link_height - share_the_love_height - 15;