SoFunction
Updated on 2025-04-10

A brief summary of the two loading progress plugins

These two plug-ins are about loading progress animations. They should be said to have their own characteristics, at least for me, they have their own advantages. I have worked on the loading progress animation one day today and have also studied a large number of (those two) loading progress animations, which can be considered as having a preliminary understanding of the loading progress animation.

NProgress is based on jquery, and the version must be >1.8

API:

() — Start progress bar
(0.4) — Set the progress to a specific percentage position
() — Increase progress in small amounts
() — Mark the progress bar as completed

Introduced:

<link rel="stylesheet" type="text/css" href="css/" rel="external nofollow" >
 <script src="js/" type="text/javascript"></script><br>//besidesjqueryTo introduce

use:

<script>
$(function() {
 ();
 $(window).load(function() {
 ();
 });
</script>

Custom animation styles:

Writing the style we defined into a script tag is a trick.

&lt;script type="text" &gt;&lt;br&gt;&lt;div class="splash card"&gt;&lt;br&gt; &lt;p class="lead" style="text-align:center"&gt;Don't come back,Go away immediately...&lt;/p&gt;
 &lt;div class="progress"&gt;
 &lt;div class="mybar" role="bar"&gt;
 &lt;/div&gt;
 &lt;/div&gt;
&lt;/div&gt;&lt;br&gt;&lt;/script&gt;

This is css

html,body,iframe{
 margin: 0;
 padding: 0;
}
#nprogress{
 position: fixed;
 top: 0;
 right: 0;
 bottom: 0;
 left: 0;
 background-color: #f7f7f7;
 z-index: 999;
}
.spinner-icon{
 display: none!important;
}
.splash {
 position:absolute;
 top:40%;
 left:0;
 right:0;
 margin: auto;
 }
 .splash img {
 display: block;
 margin-left: auto;
 margin-right: auto;
 height: 100px;
 width: 100px;
 }
 .card {
 background-color: #f7f7f7;
 padding: 20px 25px 15px;
 margin: 0 auto 25px;
 width: 380px;
 }
 .mybar {
 background: #29d;
 height:10px;
 }
 .progress {
 height: 10px;
 overflow: hidden;
 }

The js code becomes like this:

&lt;script type="text/javascript"&gt;
 $(function(){
  ({
  template: $('#myId').html() // template is the attribute used to set animation styles  });
  ();
 });
 $(window).load(function(){
  ();
 })
 &lt;/script&gt;

Summary: Controls when the animation starts, ends, and the animation styles that have been loaded in js.

The two key pointers in a custom style are the role attribute:

role=bar: horizontal loading bar

role=spinner small rotation circle

Example 2: (CSS is omitted)

<script type="text" >
<em ><em ><div class="bar" role="bar" style="display=block"><br><div class="peg"></div><br></div><br><div class="spinner" role="spinner"><br><div class="spinner-icon"></div><br></div></em></em>
</script>

API:

: Start displaying the progress bar. If you do not use AMD or Browserify to load the module, this will be executed by default.
: Progress bar reloads and displays.
: Hide the progress bar and stop loading.
: Monitor one or more request tasks.
: Ignore one or more request tasks.

usage:

&lt;head&gt;
 &lt;script src="/pace/"&gt;&lt;/script&gt;
 &lt;link href="/pace/themes/" rel="external nofollow" rel="stylesheet" /&gt; &lt;br&gt;&lt;!-- HerecssThe style determines the style of the loading progress animation --&gt;
&lt;/head&gt;

Change the animation style:

Many loading progress animations have been designed in the pace, just change the css file.

Summarize:

The advantage of pace is to directly introduce files. You don’t need to write any code yourself, but you have a load progress animation. It’s just that there is a disadvantage. The load progress animation provided by the official website does not have a mask layer.

Of course, you can set it yourself (I don't know);

The above is a brief summary of the two loading progress plug-ins introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!