

GitHub - andreupifarre/preload-it: A tiny 1kb JavaScript library for preloading...
source link: https://github.com/andreupifarre/preload-it
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md
preload-it
A tiny 1kb JavaScript library for preloading assets on the browser via XHR2. It provides the ability to load assets of different file types and composite progress events.
Installing
If you use npm, npm i preload-it
. Otherwise, download the latest release. The released bundle supports anonymous AMD, CommonJS, and vanilla environments. You can load directly from unpkg. For example:
<script src="https://unpkg.com/preload-it@latest/dist/preload-it.js"></script>
For the minified version:
<script src="https://unpkg.com/preload-it"></script>
preload-it is written using ES2015 modules. To import preload-it into an ES2015 application, import into a namespace:
<script type="module">
import preload from 'https://unpkg.com/preload-it@latest/dist/preload-it.esm.min.js';
</script>
Getting started
const preload = Preload(); preload.fetch([ 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4', 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4', 'https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg' ]).then(items => { // use either a promise or 'oncomplete' console.log(items); }); preload.oncomplete = items => { console.log(items); } preload.onprogress = event => { console.log(event.progress + '%'); } preload.onfetched = item => { console.log(item); }
License
Released for free under the MIT license, which means you can use it for almost any purpose (including commercial projects). We appreciate credit where possible, but it is not a requirement.
MIT.
Recommend
-
143
Symfony 4: HTTP/2 Push and Preloading A few months ago, I’ve contributed a new component to Symfony: WebLink. By implementing cutting edge web standards, namely...
-
89
On startup, PHP may execute a script defined by opcache.preload configuration directive.All function and classes loaded by this script became permanent and available to all the following requests.For example, it's possible to preload almost whol...
-
55
The PHP Interpreter. Contribute to php/php-src development by creating an account on GitHub.
-
65
« back — written by Brent on July 05, 2019 Prel...
-
34
HistoryAllCommentsChangesGit/SVN commitsRelated reports [2019-12-09 09:00 UTC] [email protected] -Statu...
-
43
聊一聊 webpack 中的 preloading 和 Prefetching 提到 Preloading 和 Prefetching 就不得不先说一下代码分割,通过下面的例子我们来说明为什么需要代码分割? // index.js import _ from 'lodash'; // 假设大小为 1...
-
28
Join GitHub today GitHub is home to over 50 million developers working together to host and review code, manage projects, and build sof...
-
26
« back — written by Brent on January 10, 2020 P...
-
7
Linux Steam client screensaver issue workaround LD_PRELOAD library, while letting games disable screensaver · GitHub Instantly shar...
-
10
Best Ways to Preload Images Using JavaScript, CSS and HTML Monty Shokeen Last updated Jan 30, 2023...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK