Giter Site home page Giter Site logo

preload's Introduction

preLoad

GitHub forks GitHub stars

图片预加载介绍

从字面上来看:预,就是预先;预加载:即预先提前加载。

图片预先加载到浏览器中,访问者可以顺利的网站上浏览冲浪,并享受极快的加载速度;

我们为什么需要预加载?

某些情况下丰富的图片资源,带来更好的用户体验的同时,也降低的我们的性能,有时候,我们在观看页面时需要不断的等待页面加载图片,带来的极差的用户体验(这种表现在画廊,有大量照片、图片占据比例大的地方尤为明显);

用法

下载

git clone [email protected]:okaychen/preload.git

使用

<script src="path/prelaod.js"></script>

或者

import prelaod from 'path/prelaod.js'

实例化对象:

插件名:preload;

参数:图片(数组或者String类型),方法;

方法:目前插件中提供eachall方法;

  • each 每一张图片加载完成之后执
  • all 所有图片加载完毕后执行

示例:

$.preload(imgs,{
    each:function(count){
        //...一张图片加载完后做处理
    },
    all:function(){
        //...所有图片加载完毕之后做处理
    }
});

目录结构描述

目录大体结构如下

preload
│   README.md 
│   .gitattributes
│   index.jquery.html
|
└───css
│   │   prelaod.css
│   
└───images  
|
└───js
    │   jquery.min.js
    │   preload.jquery.js

preload's People

Contributors

okaychen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.