Home > Web Front-end > JS Tutorial > body text

pace.js – Web page automatic loading progress bar plug-in

高洛峰
Release: 2016-12-16 16:45:15
Original
1314 people have browsed it

Introduce Pace.js into the page, and the page will automatically monitor your requests (including Ajax requests). When the event loop lags, the loading status and progress will be recorded on the page. This plug-in has good compatibility and is compatible with all mainstream plug-ins above IE8. What’s more, its power is that you can also introduce the theme style of the loading progress bar. You can choose any color and multiple animation effects (such as simplicity, flash , MAC OSX, left padding, top padding, counter and bounce, etc. animation effects), if you are good at modifying CSS animations, then you can make unlimited possibilities of animations to add personalized features to your website!

How to use

Introduce Pace.js and theme files:

<head>
  <script src="/pace/pace.js"></script>
  <link href="/pace/themes/pace-theme-barber-shop.css" rel="external nofollow"  rel="stylesheet" />
</head>
Copy after login

Custom configuration

Pace.js will be automatically loaded into the page without being hooked to any code, and the progress will be automatically detected. If you want to make some adjustments, you can set window.paceOptions to customize the configuration:

  paceOptions = {
  // Disable the &#39;elements&#39; source
  elements: false,
  
  // Only show the progress on regular and ajax-y page navigation,
  // not every request
  restartOnRequestAfter: false
  }
Copy after login

You can also put the custom settings in the script tag, for example:

<script data-pace-options=&#39;{ "ajax": false }&#39; src=&#39;pace.js&#39;></script>
Copy after login

If you use AMD or Browserify to load the module, you It can be set like this (for example: start):

define([&#39;pace&#39;], function(pace){
  pace.start({
    document: false
  });
});
Copy after login

Use API

Pace.js public API list:

Pace.start: Start displaying the progress bar, if you are not using AMD or Browserify to load the module, This will be executed by default.

Pace.restart: The progress bar is reloaded and displayed.

Pace.stop: Hide the progress bar and stop loading.

Pace.track: Monitor one or more request tasks.

Pace.ignore: Ignore one or more request tasks.



For more articles on pace.js – Web page automatic loading progress bar plug-in, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template