Skip to content

Commit 7b71f96

Browse files
authored
For 3.8.0 (#132)
1 parent a0e1c0a commit 7b71f96

16 files changed

+999
-1014
lines changed

.editorconfig

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
root = true
22

3-
[*.js]
3+
[*]
44
charset = utf-8
55
indent_size = 2
66
indent_style = space
77
end_of_line = lf
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.md]
12-
trim_trailing_whitespace = true
13-
end_of_line = crlf
11+
[*.html]
12+
indent_size = 4

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019-2023 Mai Nhut Tan <shin@shin.company>
3+
Copyright (c) 2019-2024 Mai Nhut Tan <shin@shin.company>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+198-209
Large diffs are not rendered by default.

demo/index.html

+182-190
Large diffs are not rendered by default.

dist/defer.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/defer_plus.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/about.md

+32-65
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,55 @@
1-
# Package @shinsenter/defer.js
1+
# @shinsenter/defer.js
22

3-
🥇 A JavaScript micro-library that helps you lazy load (almost) anything. Defer.js is zero-dependency, super-efficient, and Web Vitals friendly.
3+
🥇 A lightweight JavaScript library that helps you lazy load (almost) anything. Defer.js is dependency-free, highly efficient, and optimized for Web Vitals.
44

55
[![NPM](https://img.shields.io/npm/l/@shinsenter/defer.js)](https://code.shin.company/defer.js/blob/master/LICENSE)
6-
[![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@shinsenter/defer.js)](https://snyk.io/advisor/npm-package/@shinsenter/defer.js)
7-
[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/shinsenter/defer.js)](https://www.codefactor.io/repository/github/shinsenter/defer.js)
86
[![GitHub Release Date](https://img.shields.io/github/release-date/shinsenter/defer.js)](https://code.shin.company/defer.js/releases)
97
[![GitHub package.json version](https://img.shields.io/github/package-json/v/shinsenter/defer.js)](https://code.shin.company/defer.js/releases)
108
[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@shinsenter/defer.js)](https://www.npmjs.com/package/@shinsenter/defer.js)
119
[![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hm/@shinsenter/defer.js)](https://www.jsdelivr.com/package/npm/@shinsenter/defer.js)
1210

13-
14-
* * *
15-
11+
> 💡 [View document in other languages](#documentation-in-other-languages)
1612
1713
## Introduction
1814

19-
Lagging Big CSS files, slow JavaScript, or bulky media resources can cause issues with your website's Web Vitals, leading to a slow and frustrating user experience. But what if you could fully defer these resources and improve your website's load speed?
20-
21-
By using Defer.js, you can say goodbye to these issues! With its lazy loading capabilities, dependency-free design, lightning-fast performance, and hard-won experience, Defer.js is the perfect solution for optimizing your website's Web Vitals. Whether you're using a modern or legacy browser, Defer.js makes it easy to enhance your website's user experience with lightning-fast loading times.
22-
23-
[![NPM](https://nodei.co/npm/@shinsenter/defer.js.png?downloads=true)](https://www.npmjs.com/package/@shinsenter/defer.js)
24-
25-
- **Package**: [@shinsenter/defer.js](https://www.npmjs.com/package/@shinsenter/defer.js)
26-
- **Version**: 3.7.0
27-
- **Author**: Mai Nhut Tan <shin@shin.company>
28-
- **Copyright**: 2019-2023 SHIN Company <https://code.shin.company/>
29-
- **License**: [MIT](https://code.shin.company/defer.js/blob/master/LICENSE)
30-
31-
---
32-
33-
## Document in other languages
34-
35-
> [NEED HELP] Let's make the documentation and examples better together!
15+
Sluggish Big CSS files, slow JavaScript, or bulky media resources can negatively impact your website's Web Vitals, leading to a slow and frustrating user experience. But what if you could seamlessly defer these resources and boost your website's load speed?
3616

37-
### 日本語
38-
39-
日本人のはこちらの記事を参考にしていただければ幸いです。
40-
41-
- アタルさんの[Defer.js ドキュメント (日本語訳)](https://blog.gadgets-geek.net/2023/02/deferjs-doc-japanese.html)
42-
- あトんさんの[記事](https://www.heavy-peat.com/2022/02/defer.html)
43-
- リモスキさんの[記事](https://www.limosuki.com/2022/06/twitter-lazyload-deferjs.html)
44-
45-
#### Credits
46-
47-
I would like to express warm thanks to [@Ataruchi](https://twitter.com/Ataruchi), [@HeavyPeat](https://twitter.com/HeavyPeat) and [Limosuki](https://www.limosuki.com/) for their articles in Japanese.
48-
49-
***
17+
By utilizing Defer.js, you can bid farewell to these issues! With its lazy loading capabilities, dependency-free design, lightning-fast performance, and hard-won experience, Defer.js is the ultimate solution for optimizing your website's Web Vitals. Whether you're using a modern or legacy browser, Defer.js makes it a breeze to enhance your website's user experience with blazing-fast loading times.
5018

5119
## Why Choose Defer.js
5220

53-
- 🧩 Lazy load almost anything with ease
54-
- 🚀 Lightweight and fast, with no dependencies
55-
- 🤝 Effortlessly integrates with your favorite frameworks
21+
- 🧩 Effortlessly lazy load almost anything
5622
- 🔰 Easy to use, even for beginners
23+
- 🚀 Lightweight and blazingly fast, with no dependencies
5724
- ⚡️ Super tiny (minzipped size is around 1KB)
25+
- 🤝 Seamlessly integrates with your favorite frameworks
5826
- 🦾 Optimized for the latest Web Vitals standards
5927
- 📱 Optimized for use on smartphones
60-
- ✅ Supports legacy browsers like Internet Explorer 9
28+
- ✅ Supports legacy browsers like Internet Explorer 9 <sup>[(*)](#browser-support)</sup>
29+
30+
## Contributing
6131

62-
<sup>*Legacy browsers like Internet Explorer 9 require `IntersectionObserver` polyfill.</sup>
32+
[![NPM](https://nodei.co/npm/@shinsenter/defer.js.png?downloads=true)](https://www.npmjs.com/package/@shinsenter/defer.js)
6333

64-
## Browser Support
34+
- **Package**: [@shinsenter/defer.js](https://www.npmjs.com/package/@shinsenter/defer.js)
35+
- **Version**: 3.8.0
36+
- **Author**: Mai Nhut Tan <shin@shin.company>
37+
- **Copyright**: 2019-2024 SHIN Company <https://code.shin.company/>
38+
- **License**: [MIT](https://code.shin.company/defer.js/blob/master/LICENSE)
6539

66-
Defer.js is compatible with all modern browsers, including:
67-
- 🖥 IE9+ / Edge
68-
- 🖥 Firefox 4+
69-
- 🖥 Safari 3+
70-
- 🖥 Chrome
71-
- 🖥 Opera
72-
- 📱 Android 4+
73-
- 📱 iOS 3.2+
40+
If you find the project useful, please give it a star or consider donating via [PayPal](https://www.paypal.me/shinsenter).
41+
You can also [open a discussion](https://github.com/shinsenter/defer.js/discussions/new/choose) on Github if you have any idea to improve the library.
7442

75-
---
43+
[![Donate via PayPal](https://img.shields.io/badge/Donate-Paypal-blue)](https://www.paypal.me/shinsenter) [![Become a Stargazer](https://img.shields.io/badge/Become-Stargazer-yellow)](https://code.shin.company/defer.js/stargazers) [![Report an issue](https://img.shields.io/badge/New-Discussions-green)](https://code.shin.company/defer.js/discussions/new/choose)
7644

77-
## Known issues
45+
Your support helps maintain and improve these project for the community.
7846

79-
- [Discussion #122](https://code.shin.company/defer.js/discussions/122):
80-
In iOS Safari, the first `click` event may not work when using `Defer.all()` with the `waitForUserAction` argument set to `true` and one of deferred scripts make a DOM change.
47+
I appreciate you respecting my intellectual efforts in creating this library.
48+
If you intend to copy or use ideas from this project, please give proper credit.
8149

8250
---
8351

84-
## Getting started
52+
## Getting Started
8553

8654
Defer.js is an easy-to-use library that will help boost your website's performance by reducing loading times. Here's how to get started:
8755

@@ -95,15 +63,15 @@ Add the Defer.js library to your page by including a `<script>` tag just below t
9563
<title>My Awesome Page</title>
9664

9765
<!-- Add Defer.js here -->
98-
<script src="https://cdn.jsdelivr.net/npm/@shinsenter/defer.js@3.7.0/dist/defer.min.js"></script>
66+
<script src="https://cdn.jsdelivr.net/npm/@shinsenter/defer.js@3.8.0/dist/defer.min.js"></script>
9967

10068
<!-- ... -->
10169
</head>
10270
```
10371

104-
### Inlining the library
72+
### Inlining the Library
10573

106-
To save an HTTP request, you can even inline the entire Defer.js library by copying its content from the [defer.min.js](https://cdn.jsdelivr.net/npm/@shinsenter/defer.js@3.7.0/dist/defer.min.js) and replacing the comments in the script tag with its content.
74+
To save an HTTP request, you can even inline the entire Defer.js library by copying its content from the [defer.min.js](https://cdn.jsdelivr.net/npm/@shinsenter/defer.js@3.8.0/dist/defer.min.js) and replacing the comments in the script tag with its content.
10775

10876
```html
10977
<head>
@@ -117,34 +85,33 @@ To save an HTTP request, you can even inline the entire Defer.js library by copy
11785
</head>
11886
```
11987

120-
### Compatibility with older versions
88+
### Compatibility with Older Versions
12189

122-
If you're using an older version of Defer.js, you can use `defer_plus.min.js` instead of `defer.min.js`.
90+
If you're using Defer.js v1.x, you can use `defer_plus.min.js` instead of `defer.min.js` without wondering about migrations.
12391

12492
```html
12593
<head>
12694
<meta charset="UTF-8" />
12795
<title>My Awesome Page</title>
12896

12997
<!-- Put defer_plus.min.js here -->
130-
<script src="https://cdn.jsdelivr.net/npm/@shinsenter/defer.js@3.7.0/dist/defer_plus.min.js"></script>
98+
<script src="https://cdn.jsdelivr.net/npm/@shinsenter/defer.js@3.8.0/dist/defer_plus.min.js"></script>
13199

132100
<!-- ... -->
133101
</head>
134102
```
135103

136-
### For OLD browsers (such as IE9)
104+
### For OLD Browsers (such as IE9)
137105

138106
To enhance performance for legacy browsers that don't support the `IntersectionObserver` feature, you can load the IntersectionObserver polyfill library after the `defer.min.js` script tag.
139107

140108
```html
141109
<script>/* Defer.js content */</script>
142110

143111
<!-- Add the IntersectionObserver Polyfill for legacy browsers -->
144-
<script>'IntersectionObserver'in window||document.write('<script src="https://cdn.jsdelivr.net/npm/@shinsenter/defer.js@3.7.0/dist/polyfill.min.js"><\/script>');</script>
112+
<script>'IntersectionObserver'in window||document.write('<script src="https://cdn.jsdelivr.net/npm/@shinsenter/defer.js@3.8.0/dist/polyfill.min.js"><\/script>');</script>
145113
```
146114

147115
*NOTE*: Modern browsers support the `IntersectionObserver` feature, so you don't have to worry about adding the polyfill if you don't have legacy browsers in mind.
148116

149117
---
150-

0 commit comments

Comments
 (0)