From 76d2861c4ae80134e8d420f38147d7bbbdf4c0ae Mon Sep 17 00:00:00 2001 From: Captain Nick Lucifer* <86857450+c4p-n1ck@users.noreply.github.com> Date: Mon, 7 Nov 2022 22:01:55 +0545 Subject: [PATCH 1/3] Update yokto.js Thanks to: https://stackoverflow.com/a/48621397/19661445 --- yokto.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/yokto.js b/yokto.js index 5025d9b..8cafba7 100644 --- a/yokto.js +++ b/yokto.js @@ -23,10 +23,23 @@ const _ = (parentSelector, tag, attrs, innerText) => { }; parentElem.appendChild(elem); }; -const $$ = (callback) => { - window.addEventListener("DOMContentLoaded", () => { - callback(); +const $$ = (fn) => { + if (typeof fn !== 'function') { + throw new Error('Argument passed to ready should be a function'); + } + + if (document.readyState != 'loading') { + fn(); + } else if (document.addEventListener) { + document.addEventListener('DOMContentLoaded', fn, { + once: true // A boolean value indicating that the listener should be invoked at most once after being added. If true, the listener would be automatically removed when invoked. }); + } else { + document.attachEvent('onreadystatechange', function() { + if (document.readyState != 'loading') + fn(); + }); + } }; const $_ = async (method, url, data) => { var headers = {}; From 758669a7bca7c7da86a63d8c5e6989c6a3af755e Mon Sep 17 00:00:00 2001 From: Captain Nick Lucifer* <86857450+c4p-n1ck@users.noreply.github.com> Date: Mon, 7 Nov 2022 22:05:35 +0545 Subject: [PATCH 2/3] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c3401a5..a997d74 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ > Yokto simply means smallest SI prefix. -No framework framework 😛 +Simple/tiny jQuery replacement/alternative library 😛 -YoktoJS is supposed to be used with VanillaJS, using any frameworks* parallelly might bug things up! --- -\*frameworks as in: jQuery, etc. +YoktoJS is supposed to be used with VanillaJS, using any library/frameworks* parallelly might bug things up! +--- +\*library/frameworks as in: jQuery, etc. (Basically any library/framework that uses `$_`, `$`, `$$`, `_`, `__` since Yokto uses it.) From 1a4a53e9c00ddc71e6256e227473b201ff528b26 Mon Sep 17 00:00:00 2001 From: "Prof. - Xadk3!#2580" <151055211+profxadke@users.noreply.github.com> Date: Mon, 16 Jun 2025 01:40:55 +0545 Subject: [PATCH 3/3] FML --- yokto.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yokto.js b/yokto.js index 8cafba7..15c20f2 100644 --- a/yokto.js +++ b/yokto.js @@ -45,15 +45,16 @@ const $_ = async (method, url, data) => { var headers = {}; if (data) { headers['Content-Type'] = 'application/json'; + headers['Accept'] = 'application/json'; }; const resp = await fetch(url, { method: method, - mode: 'same-origin', + mode: 'cors', cache: 'no-cache', credentials: 'same-origin', headers: headers, redirect: 'follow', - referrerPolicy: 'no-referrer', + referrerPolicy: 'unsafe-url', body: JSON.stringify(data) }); return await resp.json();