Slow loading images, best way to display temporary image? JQuery perhaps?

后端 未结 6 1088
死守一世寂寞
死守一世寂寞 2021-01-12 01:47

I am using Google Charts to display charting data in my application. Sometimes Google is slow and the charts will take a while to load. This scenario seems to be a common en

6条回答
  •  抹茶落季
    2021-01-12 02:31

    No you dont want to preload (this assumes stalling the page load while the designated images load). you jsut need to display a loading graphic.

    $(.loading).css({
      'background-image':'myLoading.gif', 
      'background-repeat: 'no-repeat', 
       height: 25, 
       width: 25
     }).load(function(){
       $(this.css({
        'background-image': null, 
         height: 'auto', 
         width: 'auto'
       });
     });
    

    Or something to that effect... note height and width should be the size of the loaing image... unless you know the size of the image youre pulling down.

提交回复
热议问题