const ready = function (cb) {// Check if the `document` is loaded completelydocument.readyState === "loading"? document.addEventListener("DOMContentLoaded", function (e) {cb();}): cb();};// Usageready(function() {// Do something when the document is ready...});