Background images loading slow

I am trying to create ionic app with background image sliding based on timer on home page.
facing issue with slow loading images.


import { Component, Input, ViewChild } from ‘@angular/core’;
import { NavController, Content } from ‘ionic-angular’;
import { BackgroundService } from ‘…/…/services’;
import { HttpErrorResponse } from ‘@angular/common/http’;

selector: ‘page-home’,
templateUrl: ‘home.html’
export class HomePage {
@ViewChild(Content) private content: Content;

private displayTime: number;
private basePath: string;
private transitionTime: string;
private images: string[];
private task: number;
constructor(public navCtrl: NavController, private backgroundService: BackgroundService) {
this.header_data = {ismenu:true,ishome:false,title:“Custom Home”};

public ngOnInit() {
data=> {
let configObject = data.config;
this.displayTime = configObject.HM_BKG_IMG_DISPLAY_TIME;
this.basePath = configObject.IMG_BASE_PATH;
this.transitionTime = configObject.HM_BKG_IMG_TRANSITION_DURATION;
this.images = configObject.HM_BKG_IMAGES;
(error: HttpErrorResponse) => {



private startImageSlideShow() {
let index = 0;
this.content.setElementStyle(‘transition-duration’, this.transitionTime);
this.task = window.setInterval(()=> {
console.log(‘Before image set *************’ + this.images[index]);
this.content.setElementStyle(‘background-image’, ‘url(’+ this.basePath + this.images[index] +’)’);
if(index >= this.images.length) {
index = 0;
console.log(‘After image set *************’);



public ngOnDestroy() {


page-home {

ion-content {
    background-size: 100% 100%;
    -webkit-transition: background-image 1s ease-in-out, -webkit-transform 200ms ease;
    transition: background-image 1s ease-in-out, transform 200ms ease;
    background-repeat: no-repeat;
    background-position: center center;
    background-color: transparent;


Please suggest me how to resolve the issue

Are these images always the same or you want it to have service for getting these images?
If it’s not place them in assets folder. It will take less time to load as service call will be removed.
Or if you want to have these images by services try ion-slides with loop true and slide timing.

Hi Hennavora,

Already placed in asserts folder, tried with out service also still facing same issue.

below is my config file

“config”: {
“HM_BKG_IMAGES”: [“tablet_bg1.png”, “tablet_bg2.png”, “tablet_bg3.png”, “tablet_bg4.png”,
“IMG_BASE_PATH”: “assets/background/”,

Attached the screenshot

Hi Heenovora,

Tried ion-slide, image loading is good but image not fitted to slider content area, any idea how to fit image.

did you tried this with slides?

try implementing this logic with your file.

use object-fit property or background-size property to set it correctly.
Object-fit and background-image

use this css to set content to the start of slides

ion-slide.swiper-slide {
    align-items: flex-start;

default for slides is center.

Hi Hennavora,

Thank you, it working with slides after adding

    ion-slide.swiper-slide {

        background-size: 100% 100%;