From 16692e341ea1ea747c015e99bac6b2fd09462d93 Mon Sep 17 00:00:00 2001 From: Shin <2082119+shinsenter@users.noreply.github.com> Date: Mon, 5 Sep 2022 12:54:12 +0900 Subject: [PATCH] For v3.3.0 (#118) --- .build/.minify | 2 +- README.md | 44 +++++++----- demo/index.html | 18 ++--- dist/defer.min.js | 4 +- dist/defer_plus.min.js | 4 +- dist/polyfill.min.js | 2 +- docs/about.md | 14 ++-- docs/apis.md | 30 +++++--- docs/index.md | 44 +++++++----- package-lock.json | 4 +- package.json | 4 +- src/defer.js | 152 +++++++++++++++++++++-------------------- src/docs.js | 33 ++++++--- 13 files changed, 203 insertions(+), 152 deletions(-) diff --git a/.build/.minify b/.build/.minify index f0ffd00..77ebd9d 100644 --- a/.build/.minify +++ b/.build/.minify @@ -14,7 +14,7 @@ "wrap_iife": true }, "annotations": false, - "ie": false, + "ie": true, "keep_fargs": false, "keep_fnames": false, "module": false, diff --git a/README.md b/README.md index 72b7cb6..c6a455b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Package @shinsenter/defer.js -🥇 A JavaScript library that helps you lazy load (almost) anything. It's zero-dependency, super-efficient, and Web Vitals friendly. +🥇 A JavaScript micro-library that helps you lazy load (almost) anything. It's zero-dependency, super-efficient, and Web Vitals friendly. [![NPM](https://img.shields.io/npm/l/@shinsenter/defer.js)](https://code.shin.company/defer.js/blob/master/LICENSE) [![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@shinsenter/defer.js)](https://snyk.io/advisor/npm-package/@shinsenter/defer.js) @@ -16,7 +16,7 @@ [![NPM](https://nodei.co/npm/@shinsenter/defer.js.png?downloads=true)](https://www.npmjs.com/package/@shinsenter/defer.js) - **Package**: [@shinsenter/defer.js](https://www.npmjs.com/package/@shinsenter/defer.js) -- **Version**: 3.2.0 +- **Version**: 3.3.0 - **Author**: Mai Nhut Tan - **Copyright**: 2022 AppSeeds - **License**: [MIT](https://code.shin.company/defer.js/blob/master/LICENSE) @@ -28,7 +28,7 @@ ## Introduction -Big CSS files, slow javascript (third-party add-ons, etc.), +Big CSS files, slow JavaScript (third-party add-ons, etc.), or media resources (photos, videos, iframes) on your website may cause [Web Vitals](https://web.dev/vitals/) issues in real scenarios. @@ -80,7 +80,7 @@ Just put a ` + @@ -96,7 +96,7 @@ Because `defer.min.js` is optimized to a very tiny file size, you can even inlin My Awesome Page - + @@ -114,7 +114,7 @@ just use `defer_plus.min.js` instead of `defer.min.js`. My Awesome Page - + @@ -132,7 +132,7 @@ right after the `defer.min.js` script tag as the following example: - + ``` *HINT*: Modern browsers support `IntersectionObserver` feature, @@ -274,11 +274,14 @@ You can fully defer any script tag by setting its `type` attribute to `deferjs`. This trick also works perfectly with ` ``` @@ -303,7 +306,7 @@ Before: After: ```html @@ -311,11 +314,16 @@ After: **Example** Using your value for the type attribute, such as `type="my-magic"`: -If you hate using the `type="deferjs"` attribute, you can even choose yours. +If you hate using the `type="deferjs"` attribute, +you can even choose yours by using the `Defer.all()` function. + +Notice: To avoid unexpected behavior when using +the `Defer.all()` function to delay the execution of script tags, +you should call run `Defer.all()` with a regular script tag. ```html - + @@ -82,13 +82,13 @@

Using magic type="deferjs" attribute:

will not execute unless the user starts interacting with your page.
Note: - Preload hints feature was added since v3.2 + Resource hints feature was added since v3.2 as it is recommended to prevent issues called Taming the Waterfall. This feature is discussed at #112.
@@ -110,13 +110,13 @@

Using your value for the type attribute, such as type="my-magic" will not execute unless the user starts interacting with your page.
Note: - Preload hints feature was added since v3.2 + Resource hints feature was added since v3.2 as it is recommended to prevent issues called Taming the Waterfall. This feature is discussed at #112.

+ @@ -96,7 +96,7 @@ Because `defer.min.js` is optimized to a very tiny file size, you can even inlin My Awesome Page - + @@ -114,7 +114,7 @@ just use `defer_plus.min.js` instead of `defer.min.js`. My Awesome Page - + @@ -132,7 +132,7 @@ right after the `defer.min.js` script tag as the following example: - + ``` *HINT*: Modern browsers support `IntersectionObserver` feature, diff --git a/docs/apis.md b/docs/apis.md index e24a6dd..576bd39 100644 --- a/docs/apis.md +++ b/docs/apis.md @@ -135,11 +135,14 @@ You can fully defer any script tag by setting its `type` attribute to `deferjs`. This trick also works perfectly with ` ``` @@ -164,7 +167,7 @@ Before: After: ```html @@ -172,11 +175,16 @@ After: **Example** Using your value for the type attribute, such as `type="my-magic"`: -If you hate using the `type="deferjs"` attribute, you can even choose yours. +If you hate using the `type="deferjs"` attribute, +you can even choose yours by using the `Defer.all()` function. + +Notice: To avoid unexpected behavior when using +the `Defer.all()` function to delay the execution of script tags, +you should call run `Defer.all()` with a regular script tag. ```html + @@ -96,7 +96,7 @@ Because `defer.min.js` is optimized to a very tiny file size, you can even inlin My Awesome Page - + @@ -114,7 +114,7 @@ just use `defer_plus.min.js` instead of `defer.min.js`. My Awesome Page - + @@ -132,7 +132,7 @@ right after the `defer.min.js` script tag as the following example: - + ``` *HINT*: Modern browsers support `IntersectionObserver` feature, @@ -274,11 +274,14 @@ You can fully defer any script tag by setting its `type` attribute to `deferjs`. This trick also works perfectly with ` ``` @@ -303,7 +306,7 @@ Before: After: ```html @@ -311,11 +314,16 @@ After: **Example** Using your value for the type attribute, such as `type="my-magic"`: -If you hate using the `type="deferjs"` attribute, you can even choose yours. +If you hate using the `type="deferjs"` attribute, +you can even choose yours by using the `Defer.all()` function. + +Notice: To avoid unexpected behavior when using +the `Defer.all()` function to delay the execution of script tags, +you should call run `Defer.all()` with a regular script tag. ```html * ``` @@ -209,7 +213,7 @@ * After: * ```html * @@ -218,11 +222,16 @@ * @example * Using your value for the type attribute, such as `type="my-magic"`: * - * If you hate using the `type="deferjs"` attribute, you can even choose yours. + * If you hate using the `type="deferjs"` attribute, + * you can even choose yours by using the `Defer.all()` function. + * + * Notice: To avoid unexpected behavior when using + * the `Defer.all()` function to delay the execution of script tags, + * you should call run `Defer.all()` with a regular script tag. * * ```html *