title: How to efficiently load large list in ionic?
body: <p>I am trying to load a large list of elements (~630 elements) in an ionic application. I am particularly interested in optimizing the time it takes to initially load the page.</p>
  
  <p>I have tried using virtual scroll as to only load the elements on-demand. This works great as my page loads quick and there is no delay trying to load all 630 elements before the page is rendered. Instead, only items in the viewport are rendered which results in a smooth UX.</p>
  
  <p>My problem is this: </p>
  
  <p>I am using a search bar to filter the list and my implementation requires all items be loaded in the DOM to properly filter. By using virtual scroll, my filter doesn't work properly as items are not inserted into the DOM unless they are in the viewport.</p>
  
  <p>I would like to be able to have a page that loads quickly but that also can be filtered. Is there an alternative to virtual scroll that I can use to initially load my page faster? Or should I change my filter implementation?</p>
  
  <p>Here is my code:</p>
  
  <p><strong>home.html</strong></p>
  
  <pre><code>&lt;ion-searchbar (ionInput)="onSearch($event)" class="hymns-searchbar" placeholder="Search"  [showCancelButton]="shouldShowCancel"  (ionCancel)="onClear()"&gt;&lt;/ion-searchbar&gt;
  
  ...
  
  &lt;ion-content padding&gt;
    &lt;ion-list [virtualScroll]="hymns"&gt;
  
        &lt;div *virtualItem="let song; let i = index;"
         id="songItems" approxItemHeight="62px" bufferRatio="10"&gt;
  
          &lt;button ion-item clear class="hymns-list-item"
            [navPush]="songPage" [navParams]=song&gt;
              &lt;h4 class="song-title"&gt;
                  &lt;span class="song-number"&gt;{{i + 1}}&lt;/span&gt;{{ song.title }}
              &lt;/h4&gt;
              &lt;small class="song-genre"&gt;{{song.category}}&lt;/small&gt;
          &lt;/button&gt; 
        &lt;/div&gt;
    &lt;/ion-list&gt;
  &lt;/ion-content&gt;
  </code></pre>
  
  <p><strong>home.ts</strong></p>
  
  <pre><code>  public hymns: any;
    private songItems:any;
  
    ngOnInit() {
      this.hymns = songs; // Array with 630 elements
  
    }
  
    onSearch(event) {
      let val = event.target.value;
  
      if (typeof val == 'undefined') {
          // clear list
      }
      else {
        val = val.toUpperCase();
  
        this.songItems = document.querySelectorAll('#songItems');
  
        for (let i = 0; i &lt; this.hymns.length; i++) {
          let title = this.hymns[i].title;
  
          if (title.toUpperCase().indexOf(val) &gt; -1) {
            this.songItems[i].style.display = '';
          }
          else {
            this.songItems[i].style.display = 'none';
          }
        }
      }
  </code></pre>