Home is very very slow than other pages


#1

Hi

I just import my REST API Wordpress posts to ionic and everything works great

but the main page Home where all posts load there is very very slow in scrolling and load data from wordpress

maybe because it provide all posts in the page without loading

how can I make it fast ??
would something like infinite-scroll because i try to put in my code but it not working?

here’s some codes maybe it cause the slow in main page I believe there’s something wrong in mycode here

Home.ts

 constructor(public navCtrl: NavController, public wpProvider: WpProvider, public loadingCtrl: LoadingController) {
   this.presentLoading()
   this.posts = this.wpProvider.getPosts();
   this.posts.subscribe(data => 
       this.loader.dismiss());
   }

Home.html

<ion-content>
 <ion-card *ngFor="let post of posts | async" (click)="openPost(post)" tappable>
   <img [src]="post.media_url | async">
   <ion-item>
     <ion-avatar item-left>
       <img [src]="getUserImage(post.authorId)">
     </ion-avatar>
     <h2>{{ getUserName(post.authorId) }}</h2>
   </ion-item>
   <ion-card-content>
     <ion-card-title>
       {{ post.title }}
     </ion-card-title>
     <div [innerHTML]="post.excerpt"></div>
   </ion-card-content>
 </ion-card>
       
</ion-content>

could anybody anyone help me ?


#2

use virtual-scroll or infinite-scroll. Though I did see a complaint that one of those was nerfed in the latest version. Not sure whether that’s true. But those are tools explicitly built for the use case you describe.


#3

Binding to function calls can often be expensive as well, so it’s normally better to modify the data/model to have the info needed for the template.


#4

@AaronSterling I try to use virtual-scroll in html but won’t work

@SigmundFroyd
can you send any code that can fix this ?