2014-06-23 48 views
0

我使用這個代碼,我發現了一個比快我曾經有:緩慢的查詢infinitescroll在tumblr響應?

<script type="text/javascript"> 
$(window).load(function(){ 
var $wall = $('.posts'); 
$wall.imagesLoaded(function(){ 
$wall.masonry({ 
itemSelector: '.entry', 
isAnimated : false 
}); 
}); 

$wall.infinitescroll({ 
navSelector : "div#navigation", 
nextSelector : "div#navigation a#nextPage", 
itemSelector : ".entry", 
bufferPx : 2000, 
debug : false, 
errorCallback: function() { 
$('#infscr-loading').fadeOut('normal'); 
}}, 
function(newElements) { 
var $newElems = $(newElements); 
$newElems.hide(); 
$newElems.imagesLoaded(function(){ 
$wall.masonry('appended', $newElems,{isAnimated: false}, function(){$newElems.fadeIn('slow');}); 
}); 
}); $('.posts').show(500); 
}); 
</script> <script> 
$.fn.changebackgroundColor = function(msg) { 
$("#perma").css("#000"); }; </script> 

但它仍然是相當緩慢的,有一個職位的延遲加載和我想知道我可以改變什麼。我使用總共大約1100px大小的3列。

+1

如果您在發佈腳本時格式化/縮進腳本,它確實很有幫助。如果你的編輯器沒有一個好的重新格式化工具,你可以使用http://jsbeautifier.org/ –

回答

2

來自文檔:該問題可能與bufferPx屬性有關。

   bufferPx  : 40, 
      // increase this number if you want infscroll to fire quicker 
      // (a high number means a user will not see the loading message) 
      // new in 1.2 
      // default: 40 

如果調整該值沒有明顯的影響,它可能只是加載時間,具體取決於加載的數據量。

+0

謝謝,這就是我的想法。我試圖提高數字,但沒有改變任何東西,我想這是通常的加載時間。你可以把我和你使用的文件聯繫起來嗎?再次感謝。 – pikkkura

+1

我相信這是一個:https://github.com/paulirish/infinite-scroll –