title: Tumblr JS/Jquery Infinite Scroll / Masonry Glitch
body: <p>I'm new to JS/JQuery and masonry so this is probably some dumb mistake, but i've searched a lot for answers and i'm completely out of ideas.</p>
  
  <p>The issue is overlapping posts/divs.
  <img src="https://i.stack.imgur.com/hY1DG.jpg" alt="enter image description here">
  <a href="http://folkherofilms.tumblr.com/tagged/thrilljockey/chrono" rel="nofollow noreferrer">http://folkherofilms.tumblr.com/tagged/thrilljockey/chrono</a></p>
  
  <p>Here's the full theme code:</p>
  
  <pre><code>    &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;{Title}&lt;/title&gt;
          &lt;link rel="shortcut icon" href="{Favicon}"&gt;
          &lt;link rel="alternate" type="application/rss+xml" href="{RSS}"&gt;
          {block:Description}
              &lt;meta name="description" content="{MetaDescription}" /&gt;
          {/block:Description}
  
  &lt;script src="http://static.tumblr.com/cbgnuxd/KqQmy0t7l/jquery-1.7.1.min.js"&gt;&lt;/script&gt;
  &lt;script src="http://static.tumblr.com/cbgnuxd/LE0my0t7x/jquery.masonry.min.js"&gt;&lt;/script&gt;
  &lt;script src="http://static.tumblr.com/cbgnuxd/PW6my0t86/masonry.pkgd.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://static.tumblr.com/cbgnuxd/He2myzqh0/lazyyt.js"&gt;&lt;/script&gt;
  
  &lt;!-- SHARERS --&gt;
  &lt;script type="text/javascript"&gt;var switchTo5x=true;&lt;/script&gt;&lt;script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt;stLight.options({publisher:'3a7d8263-9ce0-4500-9413-f40167dad735'});&lt;/script&gt;
  
  &lt;!-- OTHER CRAP SCRIPT --&gt;
  
  &lt;script&gt;
  
  $(function(){
  
  // YT LAZY LOAD
  $('.js-lazyYT').lazyYT();
  
  // INDEX PAGE
  if (document.location.href == "http://folkherofilms.tumblr.com/") {
      window.location.href = "http://folkherofilms.tumblr.com/index";
  }
  
  if (document.location.href == "http://folkherofilms.tumblr.com/index") {
      $('body').addClass('static');
      $('.item').addClass('autoheight');
  }
  
  // CASE STUDY PAGES
  if ( document.location.href.indexOf('tagged/') &gt; -1 ) {
      $('#sidebar').fadeIn('slow');
  }
  
  // ABOUT PAGE
  
  if (document.location.href == "http://folkherofilms.tumblr.com/about") {
      $('body').addClass('static');
      $('.item img').css('width','auto');
      $('.item').addClass('autoheight');
  }
  
  // TEMPORARY PORTFOLIO PAGE
  
  if (document.location.href == "http://folkherofilms.tumblr.com/portfolio") {
      $('body').addClass('static');
      $('.item').addClass('autoheight');
  }
  
  // PORTFOLIO PAGE
  if (document.location.href == "http://folkherofilms.tumblr.com/tagged/portfolio") {
      $('#sidebar, .sharers').css('display','none');
      $('#maincontainer, #headercontainer').css('width','1040px');
      $('#maincontainer').css('top','190px');
      $('#container').css('margin-left','0px');
      $('.item').removeClass('m l autoheight');
      $('.item').addClass('s');
  }
  
  // FIELD NOTES POSTS
  if ($('.item.fieldnotes').length ) {
      $('body').addClass('static');  
      $('#disqus_things, .sharers').show();
      $('.item').addClass('autoheight');   
  
  }
  
  // FIELD NOTES PAGE
  if (document.location.href == "http://folkherofilms.tumblr.com/tagged/fieldnotes") {
      $('body').addClass('static');
      $('.item').removeClass('m s');
      $('.item img').css('width','auto');
      $('#disqus_things, .sharers').hide();
  }
  
  // CONTACT PAGE
  if (document.location.href == "http://folkherofilms.tumblr.com/contact") {
      $('body').addClass('static');
  }
  
  // DEFAULT SIZE POSTS
  $('.item:not(.m, .l)').addClass('s');
  
  // 404 PAGE
  if ($('p:contains("The URL you requested could not be found.")').length &gt; 0) { 
      $('.item, .sharers').hide();
      $('#notfound').show();
  }
  
  });
  &lt;/script&gt;
  
  &lt;!-- META --&gt;
  
  &lt;meta name="image:Background" content=""/&gt;
  &lt;meta name="image:Logo" content=""/&gt;
  &lt;meta name="image:Header Background" content=""/&gt;
  &lt;meta name="color:Text Color" content="#666"/&gt;
  &lt;meta name="color:Link Underline" content="#5c7ea5"/&gt;
  &lt;meta name="text:Disqus Shortname" content="" /&gt;
  
  &lt;!-- CSS --&gt;
  
  &lt;style&gt;
  
  html, body {height:100%}
  
  #tumblr_controls, #tumblr_controls iframe {display:none!important}
  
  body {
  margin:0;
  background-color:#ccc;
  background-image:url('{image:Background}');
  font-family:Pt Sans, Helvetica, sans-serif;
  font-size:14px;
  -webkit-font-smoothing: antialiased;
  color: {Color:Text Color};
  overflow-x:hidden;
  }
  
  .hide {display:none!important}
  
  #sitecredit {
  position:fixed;
  bottom:6px;
  right:10px;
  }
  
  #sitecredit img {width:21px;opacity:0.5}
  #sitecredit img:hover {opacity:0.9}
  
  h3 {font-size:10px}
  
  #disqus_things {display:none}
  #disqus_things .post {width:100%}
  
  #maincontainer {
  visibility:hidden;
  position: relative;
  top: 200px;
  width: 1135px;
  height:100%; /*FOR SAFARI */
  margin: 0 auto;
  padding-bottom:100px;
  }
  
  #infscr-loading {opacity:0}
  
  /* STATIC PAGES */
  
  .static #sidebar {display:none!important}
  .static #maincontainer, .static #headercontainer, .static #container {width:910px}
  .static #maincontainer {top:190px}
  .static #container {margin-left:0px}
  .static .item {width:850px;padding:10px 20px;position:relative!important;}
  .static .sharers {display:none; margin:30px;}
  .static .big {width:830px!important;height:467px!important}
  
  /* HEADER */
  
      #header {
      position:fixed;
      z-index:50;$()
      display:block;
      width:100%;
      height:130px;
      background-image:url('{image:Header Background}');
      background-color:#222;
      padding:20px 0;
      font-size:10px;
      }
  
      #headercontainer {
      position:relative;
      margin:0 auto;
      display:block!important;
      width:910px;
      transition-duration:0.5s;
      -webkit-transition-duration:0.5s;
      -moz-transition-duration:0.5s;
      -o-transition-duration:0.5s;
      }
  
      #header, #header a {
      color:#fff;
      letter-spacing:1px;
      text-decoration:none;
      }
  
      #headerlinks {
      position:relative;
      left:170x;
      }
  
      #header a {
      font-size:13px;
      }
  
      #header div, #header a {display:inline-block}
  
      #logo {
      height:100%;
      margin: 0 20px 0 30px;
      }
  
  /* SIDEBAR */
  
      #sidebar {
      position: absolute;
      display: none;
      top: 0;
      width: 100px;
      text-align: center;
      margin:0 10px;
      }
  
      #sidebar h1 {
      font-size:12px;
      font-weight:normal;
      display:block;
      border-bottom:1px solid black;
      }
  
      #sidebar a {
      display:block;
      color: #5c5959;
      padding-bottom: 2px;
      text-decoration: none;
      text-transform: capitalize;
      padding:3px;
      width:91px;
      margin:10px 0;
      background:#fff;
      text-align:center;
      font-size:11px;
      }
  
  /* POSTS */
  
  
      .item a {
      color: {Color:Text Color};
      color: #666;
      font-weight: bold;
      text-decoration: none;
      }
  
      .item a:hover {color:{Color:Link Underline}}
  
      .read_more {text-transform:uppercase}
  
      #notfound {
      display:none;
      margin: 10px 0 0 129px;
      font-style: italic;
      font-size: 20px;
      text-align: center;
      letter-spacing: 1px;
      width: 500px;
      }
      .notfound-404 {
      font-size: 300px;
      font-weight: bold;
      margin: 0 0 10px;
      font-family: arial;
      font-style: normal;
      display: block;
      line-height: 220px;
      letter-spacing: -9px;
      text-align: left;
      }
  
      #container {
      z-index: 0;
      display: inline-block;
      margin-left: 115px;
      width: 1200px;
      }
  
      .item {
      overflow:hidden;
      background-color:#fff;
      margin:10px;
      }
  
      .item img {display:block;min-width:100%;height:100%;width:auto;}
      .item p img {max-width:100%;height:auto}
  
      .item iframe {width:100%;height:100%;}
  
      div.js-lazyYT img {width:auto!important;min-width:0px;height:auto;}
      .lazyYT-title {display:none}
  
      p {margin:5px}
  
      .s {
      width:240px;
      height:200px;
      }
      .s .media {height:173px}
  
      .m {
      width: 500px;
      height:420px;
      }
      .m .media {height:392px}
  
      .text {padding:10px 0}
      .s.text, .m.text {overflow-y:auto}
      .s.text {height:180px}
      .m.text {height:400px}
  
      .l {width:1020px}
      .l.video iframe {height: 574px}
  
      .l img, .autoheight, .autoheight .media, .autoheight .media img {
      height:auto!important;
      min-height:0px;
      }
  
      .autoheight.nocaption .media {
      width:100%;
      height:auto;
      }
  
      .autoheight.nocaption .media img {
      width: 100%;
      margin: -5px 0;
      }
  
      .nocaption .media {height:100%}
  
      .nocaption img {
      min-height: 100%;
      min-width: 100%;
      width: 100%;
      height:auto;
      }
  
      /*.nocaption.s img, .nocaption.m img {min-height: 100%}*/
  
      .nocaption iframe {
      height: 106%;
      margin-top: -3%;
      display:block;
      }
  
      h1 {font-size:14px}
  
      .media {
      position:relative;
      width:100%;
      overflow:hidden;
      }
  
      .caption {
      position:relative;
      display:block;
      padding:0 10px;
      }
  
      .audio .media {height:100%}
  
      .audio .player-wrapper {
      display: inline-block;
      position: absolute;
      top: 50%;
      left: 50%;
      margin: -20px!important;
      width: 40px;
      height: 40px;
      overflow: hidden;
      }
  
      .audio_player {
      display: block;
      width: 250px;
      height: 50px;
      margin:-5px!important;
      }
  
      .audio_player iframe {position:relative}
  
      .player-wrapper {z-index:70}
  
      .audioinfo {
      opacity:0;
      position: absolute;
      z-index: 50;
      top: 0;
      left: 0;
      padding: 15px 0;
      text-align: center;
      font-weight: bold;
      width: 100%;
      height: 100%;
      color: whitesmoke;
      background: black;
      }
  
      .audio:hover .audioinfo {opacity:1}
  
  /* SHARES */
  
  .sharers {
  width: 88px;
  border-top: 1px dashed black;
  padding-top: 10px;
  padding-bottom:50px;
  text-align: center;
  margin:30px 0 0 120px;
  }
  
  .sharers span {
  width: 20px!important;
  height: 20px!important;
  background-size: 20px;
  margin: 2px;
  }
  
  .stButton .stLarge:hover {
  opacity: 1!important;
  background-position: 0!important;
  cursor:pointer;
  padding-right:0px;
  }
  
  /* LIKE REBLOG */
  
  .likereblog {display:none}
  .like .likereblog {display:block}
  
  .likereblog {padding:0px 10px 5px}
  .likereblog * {
  display:inline-block!important;
  border-bottom:none!important;
  width:15px!important;
  height:15px!important;
  }
  .likereblog a:hover {background-color:transparent}
  .likereblog svg {margin-left:10px; fill:#000}
  
  .audio .likereblog, .nocaption .likereblog {position: absolute;z-index: 9999;}
  .nocaption .likereblog, .audio .likereblog {bottom:0px}
  
  .nocaption .likereblog svg {fill:#fff}
  .nocaption .likereblog iframe {-webkit-filter:invert(1)}
  
  /* PAGES */
  
  .item.fieldnotes p img, .item.fieldnotes p iframe {
      width:auto!important;
      display:block;
      margin:0 auto;
  }
  
  &lt;/style&gt;    
  
      &lt;/head&gt;
  
  &lt;!-- BODY --&gt;
  
  &lt;body&gt;
  
  &lt;!-- MASONRY SCRIPT --&gt;
  &lt;script&gt;
  
   $(function(){
  
      // IF NOT FIELD NOTES PAGE  
      if (!$('.item').hasClass('fieldnotes')) {
  
          // UNWRAP TITLE LINKS
          $('.item .title h1').unwrap();
  
          // MASONRY
          var $container = $('#container');
  
          $container.imagesLoaded( function(){
               $container.masonry({
                  columnWidth: 1,
                  isOriginTop: true,
                  itemSelector : '.item'
               });
          });
  
      }
  
   });
  &lt;/script&gt;
  
  &lt;!-- SITE CREDIT --&gt;
  &lt;div id="sitecredit"&gt;&lt;a href="http://dinakelbermanwebdesign.com" target="blank"&gt;
  &lt;img src="http://dinakelbermanwebdesign.com/credit.png"&gt;&lt;/a&gt;
  &lt;/div&gt;
  
  
  &lt;!-- HEADER --&gt;
  &lt;div id="header"&gt;
      &lt;div id="headercontainer"&gt;
      &lt;span id="headerwrap"&gt;
      &lt;a href="http://folkherofilms.tumblr.com/index"&gt;&lt;img id="logo" src="{image:Logo}"&gt;&lt;/a&gt;
  
      &lt;div id="headerlinks"&gt;
      &lt;a href="/about"&gt;Who We Are&lt;/a&gt; &amp;#9679;   
      &lt;!--a href="/tagged/portfolio"&gt;Portfolio&lt;/a&gt; &amp;#9679;--&gt;
      &lt;a href="/fieldnotes"&gt;Field Notes&lt;/a&gt; &amp;#9679;
      &lt;a href="/contact"&gt;Contact&lt;/a&gt; &amp;#9679;
      &lt;a href="http://folkherofilms.tumblr.com/index"&gt;Home&lt;/a&gt;
      &lt;/div&gt;
  &lt;!---------------------------------------------------------------------&gt;
  
      &lt;/span&gt;
      &lt;/div&gt;   
  &lt;/div&gt;
  
  
  &lt;div id="maincontainer"&gt;
  
  &lt;!-- SIDEBAR --&gt;
  &lt;div id="sidebar"&gt;
  &lt;h1&gt;MORE PROJECTS&lt;/h1&gt;
  {block:HasPages}
  {block:Pages}
  &lt;a href="{URL}"&gt;{Label}&lt;/a&gt;
  {/block:Pages}
  {/block:HasPages}    
  
  &lt;/div&gt;
  
  &lt;div id="notfound"&gt;&lt;span class="notfound-404"&gt;404&lt;/span&gt;Page not found, please try again!&lt;/div&gt;
  
  &lt;div id="container"&gt;
  
  {block:Posts}
  
  &lt;!-- TEXT --&gt;
  
  {block:Text}
  &lt;div class="item text {TagsAsClasses}"&gt;
  
      &lt;div class="caption"&gt;
      {block:Title}
      &lt;a href="{Permalink}" class="title"&gt;&lt;h1&gt;{Title}&lt;/h1&gt;&lt;/a&gt;
      {/block:Title}
      {Body}
  
      &lt;div class="hide"&gt;
      {block:ContentSource}{SourceURL}{/block:ContentSource}
      &lt;/div&gt;
  
      &lt;/div&gt;
  
  &lt;div class="likereblog"&gt;{LikeButton color="black"}{ReblogButton}&lt;/div&gt;
  &lt;/div&gt;
  {/block:Text}
  
  &lt;!-- PHOTO --&gt;
  
  {block:Photo}
  &lt;div class="item {TagsAsClasses} photo"&gt;
  
      &lt;div class="media"&gt;&lt;img src="{PhotoURL-500}"&gt;&lt;/div&gt;
  
      {block:Caption}
      &lt;div class="caption entry"&gt;
      {Caption}
      &lt;/div&gt;
      {/block:Caption}
  
  
  &lt;div class="likereblog"&gt;{LikeButton color="black"}{ReblogButton}&lt;/div&gt;
  &lt;/div&gt;
  
      &lt;div class="hide"&gt;
      {block:ContentSource}{SourceURL}{/block:ContentSource}
      &lt;/div&gt;
  {/block:Photo}
  
  
  &lt;!-- PANORAMA --&gt;                                                       
  
  {block:Panorama}
      &lt;li class="panorama"&gt;
          {LinkOpenTag}
              &lt;img src="{PhotoURL-Panorama}" alt="{PhotoAlt}"/&gt;
          {LinkCloseTag}{block:Caption}
              &lt;div class="caption"&gt;{Caption}&lt;/div&gt;
          {/block:Caption}
  
  
  &lt;div class="likereblog"&gt;{LikeButton color="black"}{ReblogButton}&lt;/div&gt;
      &lt;/li&gt;
  
          &lt;div class="hide"&gt;
      {block:ContentSource}{SourceURL}{/block:ContentSource}
      &lt;/div&gt;
  {/block:Panorama}
  
  
  &lt;!-- PHOTOSET --&gt;
  
  {block:Photoset}
  &lt;div class="item {TagsAsClasses}"&gt;
  &lt;div class="media-photoset"&gt;
  &lt;div class="lightbox photo-slideshow" id="photoset_{PostID}" data-layout="{PhotosetLayout}"&gt;
  {block:Photos}
  
  &lt;div class="photo-data"&gt;
    &lt;div class="pxu-photo"&gt;
       &lt;a class="tumblr-box" rel="post is-item-{PostID}" href="{PhotoURL-HighRes}"&gt;
            &lt;img alt="{PhotoAlt}" src="{PhotoURL-500}" data-highres="{PhotoURL-HighRes}" data-width="{PhotoWidth-HighRes}" data-height="{PhotoHeight-HighRes}" class="{block:Exif}exif-yes {/block:Exif}{block:Caption}caption-yes{/block:Caption}" {block:Exif}data-camera="{block:Camera}{Camera}{/block:Camera}" data-iso="{block:ISO}{ISO}{/block:ISO}" data-aperture="{block:Aperture}{Aperture}{/block:Aperture}" data-exposure="{block:Exposure}{Exposure}{/block:Exposure}" data-focal="{block:FocalLength}{FocalLength}{/block:FocalLength}"{/block:Exif} {block:Caption}data-caption="{Caption}"{/block:Caption}&gt;
      &lt;/a&gt;
    &lt;/div&gt;
    &lt;div class="icons"&gt;
       &lt;span class="info"&gt;
          Info
       &lt;/span&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  {/block:Photos}
  &lt;/div&gt;
  &lt;/div&gt;
  {block:Caption}
  &lt;div class="background unrounded"&gt;
  &lt;div class="entry caption"&gt;
  {Caption}
  
  &lt;/div&gt;
  &lt;/div&gt;
  {/block:Caption}
  {block:IfTags}
  {block:HasTags} 
  &lt;div class="background unrounded tags clearfix"&gt;
  {block:Tags} 
      &lt;a href="{TagURL}"&gt;
          &lt;div class="tag"&gt;{Tag}&lt;/div&gt;
      &lt;/a&gt;
  {/block:Tags}   
  &lt;/div&gt;
  {/block:HasTags}
  {/block:IfTags}
  &lt;div class="meta"&gt;
  &lt;div class="part"&gt;
  &lt;a href="{Permalink}" title="Permalink"&gt;
  {TimeAgo}
  &lt;/a&gt;
  &lt;/div&gt;
  &lt;div class="part heart"&gt;
  &lt;a href="{Permalink}" title="Permalink"&gt;
  &lt;i class="icon-heart"&gt;&lt;/i&gt;
  &lt;div class="text heart"&gt;&lt;div class="note-counter"&gt;{NoteCount}&lt;/div&gt;&lt;/div&gt;
  &lt;/a&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
      &lt;div class="hide"&gt;
      {block:ContentSource}{SourceURL}{/block:ContentSource}
      &lt;/div&gt;
  {/block:Photoset}
  
  
  &lt;!-- VIDEO --&gt;
  
  {block:Video}
  &lt;div class="item video {TagsAsClasses}"&gt;
  
  &lt;div class="media"&gt;{VideoEmbed-700}&lt;/div&gt;
  
  {block:Caption}
  &lt;div class="caption entry"&gt;
  {Caption}
  &lt;/div&gt;
  {/block:Caption}
  
  &lt;div class="likereblog"&gt;{LikeButton color="black"}{ReblogButton}&lt;/div&gt;
  
  &lt;/div&gt;
      &lt;div class="hide"&gt;
      {block:ContentSource}{SourceURL}{/block:ContentSource}
      &lt;/div&gt;
  {/block:Video}
  
  
  &lt;!-- AUDIO --&gt;
  
  {block:Audio}
  &lt;div class="item audio {TagsAsClasses}"&gt;
  
  &lt;div class="player"&gt;
      {block:AudioPlayer}
      {block:AlbumArt}
          &lt;img src="{AlbumArtURL}" class="albumart"&gt;
          &lt;div class="player-wrapper"&gt;{AudioPlayerBlack}&lt;/div&gt;
      {/block:AlbumArt}
      {/block:AudioPlayer}
  
      {block:AudioEmbed}
      &lt;div class="background"&gt;
          &lt;div class="audioembed"&gt;{AudioEmbed-500}&lt;/div&gt;
      &lt;/div&gt;
      {/block:AudioEmbed}
  &lt;/div&gt;
  
  {block:Artist}
  &lt;div class="audioinfo"&gt;
  {Artist}&lt;br&gt;
  {block:TrackName}{TrackName}{/block:TrackName}
  &lt;/div&gt;
  {/block:Artist}
  
  
  
  &lt;div&gt;
      {block:Caption}
      &lt;div class="caption entry"&gt;{Caption}&lt;/div&gt;
      {/block:Caption}
  &lt;/div&gt;
  
  
  &lt;div class="likereblog"&gt;{LikeButton color="black"}{ReblogButton}&lt;/div&gt;
  
  &lt;/div&gt;
      &lt;div class="hide"&gt;
      {block:ContentSource}{SourceURL}{/block:ContentSource}
      &lt;/div&gt;
  {/block:Audio}
  
  {/block:Posts}
  &lt;/div&gt;  
  
  &lt;div class="sharers"&gt;
  &lt;span st_url='{Permalink}' st_title='{Title}' class='st_twitter' displayText=''&gt;&lt;/span&gt;&lt;span st_url='{Permalink}' st_title='{Title}' class='st_facebook' displayText=''&gt;&lt;/span&gt;&lt;span st_url='{Permalink}' st_title='{Title}' class='st_email' displayText=''&gt;&lt;/span&gt;
  &lt;/div&gt;
  
  &lt;!-- DISQUS --&gt;
  &lt;div id="disqus_things"&gt;
      {block:IfDisqusShortname}
  
      &lt;div class="post type-comments m {block:HighRes}l{/block:HighRes}"&gt;
      &lt;div class="background fully-rounded"&gt;
      &lt;h3 class="title"&gt;
      Comments
      &lt;/h3&gt;
      &lt;div class="entry comments"&gt;
      &lt;script type="text/javascript"&gt;
      var disqus_url = "{Permalink}"; var disqus_title ="{block:PostTitle}{PostTitle}{/block:PostTitle}";
      &lt;/script&gt;
      &lt;div id="disqus_thread"&gt;&lt;/div&gt;
      &lt;script type="text/javascript"&gt;
      var disqus_shortname = '{text:Disqus shortname}'; 
  
      function load_disqus()
      {
      (function() {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);                                                
      })();
      }
  
  
      load_disqus(function() {});
  
      &lt;/script&gt;
      &lt;noscript&gt;Please enable JavaScript to view the &lt;a href="http://disqus.com/?ref_noscript"&gt;comments powered by Disqus.&lt;/a&gt;&lt;/noscript&gt;
      &lt;a href="http://disqus.com" class="dsq-brlink"&gt;blog comments powered by &lt;span class="logo-disqus"&gt;Disqus&lt;/span&gt;&lt;/a&gt;
  
      &lt;/div&gt;
  
      {/block:IfDisqusShortname}                
  &lt;/div&gt;
  
  &lt;!-- PAGINATION FOR INFINITE SCROLL --&gt;
      &lt;div class="pagination"&gt;
      {block:Pagination}
      {block:NextPage}
      &lt;a href="{NextPage}"&gt;NEXT&lt;/a&gt;
      {/block:NextPage}
      {/block:Pagination}
      &lt;/div&gt;    
  
  &lt;/div&gt;   
  
  
  &lt;!-- IMAGE LOAD JS --&gt;
  &lt;script type="text/javascript" src="http://static.tumblr.com/cbgnuxd/l2rmz5u6v/imagesloaded.js"&gt;&lt;/script&gt;
  
  &lt;!-- INFINITE SCROLL --&gt;
  &lt;script type="text/javascript" src="http://static.tumblr.com/cbgnuxd/saomz5tvi/jquery.infinitescroll.js"&gt;&lt;/script&gt;
  
  &lt;!-- INFINITE SCROLL --&gt;
  &lt;script type="text/javascript"&gt;
  (function () {
      var $tumblelog = $('#container');
      $tumblelog.infinitescroll({
          navSelector: ".pagination",
          nextSelector: ".pagination a:last-child",
          itemSelector: ".item",
  
      loading: {
      finished: undefined,
      finishedMsg: "",
      img: "",
      msg: null,
      loadingText: "&lt;em&gt;&lt;/em&gt;",
      },
  
      },
  
      function (newElements) {
          var $newElems = $(newElements).css({
              opacity: 0
          });
          $newElems.imagesLoaded(function () {
              $newElems.animate({
                  opacity: 1
              });
  
              $('.item:not(:has(.caption))').addClass('nocaption');
  
              // IF NOT FIELD NOTES PAGE  
               if (!$('.item').hasClass('fieldnotes')) {
                  // UNWRAP TITLE LINKS
                  $('.item .title h1').unwrap();
              }
  
              // PORTFOLIO PAGE
              if (document.location.href == "http://folkherofilms.tumblr.com/tagged/portfolio") {
                  $('#sidebar, .sharers').css('display','none');
                  $('#maincontainer, #headercontainer').css('width','1040px');
                  $('#maincontainer').css('top','190px');
                  $('#container').css('margin-left','0px');
                  $('.item').removeClass('m l autoheight');
                  $('.item').addClass('s');
              }
  
              // FIELD NOTES POSTS
              if ($('.item.fieldnotes').length ) {
                  $('body').addClass('static');  
                  $('#disqus_things, .sharers').show();
                  $('.item').addClass('autoheight');   
  
              }
  
              // FIELD NOTES PAGE
              if (document.location.href == "http://folkherofilms.tumblr.com/tagged/fieldnotes") {
                  $('body').addClass('static');
                  $('.item').removeClass('m s');
                  $('.item img').css('width','auto');
                  $('#disqus_things, .sharers').hide();
              }
  
              $tumblelog.masonry('appended', $newElems);
          });
      });
      $tumblelog.imagesLoaded(function () {
          $tumblelog.masonry({
              columnWidth: function (containerWidth) {
                  return containerWidth / 100;
              }
          });
      });
  
  })();  
  
  // NOCAPTION POSTS
  $('.item:not(:has(.caption))').addClass('nocaption');
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  
  &lt;script&gt;
  $(function(){
      // SITE LOADING
  $(window).load(function() {
      $("#maincontainer").css('visibility','visible');
  });
  
  })
  &lt;/script&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>I've tried a variety of solutions and the glitch keeps getting "fixed" but then coming back.  Could Tumblr be messing with the JS somehow?</p>