Replaced ifvisible.js with simple drop-in to handle prefetch messages

This commit is contained in:
djmaze 2020-08-13 21:25:42 +02:00
parent 2f48128ff3
commit 382aef7ebb
6 changed files with 57 additions and 16 deletions

View file

@ -74,26 +74,27 @@ Things might work in Edge 15-18, Firefox 47-62 and Chrome 54-68 due to one polyf
* Removed momentjs (localization still used)
* Removed opentip (use CSS)
* Replaced Autolinker with simple https/email detection
* Replaced ifvisible.js with simple drop-in replacement
|js/* |1.14.0 |native |gzip 1.14 |gzip |
|----------- |--------: |--------: |--------: |--------: |
|admin.js |2.130.942 |1.119.218 | 485.481 | 271.178 |
|app.js |4.184.455 |2.829.958 | 932.725 | 659.546 |
|admin.js |2.130.942 |1.119.128 | 485.481 | 271.258 |
|app.js |4.184.455 |2.829.541 | 932.725 | 659.696 |
|boot.js | 671.522 | 44.029 | 169.502 | 15.460 |
|libs.js | 647.614 | 318.711 | 194.728 | 99.162 |
|libs.js | 647.614 | 316.107 | 194.728 | 98.214 |
|polyfills.js | 325.834 | 0 | 71.825 | 0 |
|TOTAL js |7.960.367 |4.311.916 |1.854.261 |1.045.346 |
|TOTAL js |7.960.367 |4.308.805 |1.854.261 |1.044.628 |
|js/min/* |1.14.0 |native |gzip 1.14 |gzip |
|--------------- |--------: |--------: |--------: |--------: |
|admin.min.js | 252.147 | 151.652 | 73.657 | 43.325 |
|app.min.js | 511.202 | 377.227 |140.462 | 99.095 |
|admin.min.js | 252.147 | 151.632 | 73.657 | 43.313 |
|app.min.js | 511.202 | 377.163 |140.462 | 99.062 |
|boot.min.js | 66.007 | 5.589 | 22.567 | 2.333 |
|libs.min.js | 572.545 | 303.360 |176.720 | 93.728 |
|libs.min.js | 572.545 | 300.211 |176.720 | 92.698 |
|polyfills.min.js | 32.452 | 0 | 11.312 | 0 |
|TOTAL js/min |1.434.353 | 837.828 |424.718 |238.481 |
|TOTAL js/min |1.434.353 | 834.595 |424.718 |237.406 |
596.525 bytes (186.237 gzip) is not much, but it feels faster.
599.758 bytes (187.312 gzip) is not much, but it feels faster.
|css/* |1.14.0 |native |

View file

@ -460,7 +460,6 @@ export const ContactPropertyType = {
*/
export const Magics = {
'EventWhichMouseMiddle': 3,
'ifvisibleIdle10s': 10,
'BitLength2048': 2048,
'BitLength1024': 1024,

46
dev/External/ifvisible.js vendored Normal file
View file

@ -0,0 +1,46 @@
(() => {
const doc = document,
visible = "visible",
wakeUp = () => {
clearTimeout(timer);
if (status !== visible) {
status = visible;
}
timer = setTimeout(() => {
if (status === visible) {
status = "idle";
dispatchEvent(new CustomEvent("idle"));
}
}, 10000);
};
var initialized = false,
status = visible,
timer = false;
function init() {
if (initialized) {
return true;
}
doc.addEventListener("visibilitychange", () => {
status = doc.visibilityState;
doc.hidden || wakeUp();
}, false);
initialized = true;
wakeUp();
doc.addEventListener("mousemove", wakeUp);
doc.addEventListener("keyup", wakeUp);
doc.addEventListener("touchstart", wakeUp);
addEventListener("scroll", wakeUp);
}
window.ifvisible = {
idle: callback => {
init();
addEventListener("idle", callback);
},
now: () => {
init();
return status === visible;
}
};
})();

View file

@ -84,7 +84,6 @@
"gulp-through": "0.4.0",
"gulp-util": "3.0.8",
"gulp-zip": "5.0.1",
"ifvisible.js": "1.0.6",
"jquery": "^3.5.1",
"knockout": "3.4.2",
"knockout-sortable": "1.2.0",

View file

@ -89,7 +89,7 @@ config.paths.js = {
'vendors/lightgallery/dist/js/lg-thumbnail.min.js',
'vendors/lightgallery/dist/js/lg-zoom.min.js',
'vendors/lightgallery/dist/js/lg-autoplay.min.js',
'node_modules/ifvisible.js/src/ifvisible.min.js'
'dev/External/ifvisible.js'
]
},
app: {

View file

@ -3697,10 +3697,6 @@ iferr@^0.1.5:
version "0.1.5"
resolved "https://registry.yarnpkg.com/iferr/-/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501"
ifvisible.js@1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/ifvisible.js/-/ifvisible.js-1.0.6.tgz#52eb151ce89c56f15316226462e892d1f8451261"
ignore-walk@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8"