by mg · 3y ago · 0 comments
https://github.com/no-gravity/dqs.js
Which turns document.querySelector('.some .thing') into dqs('.some .thing').
The other one is Handlebars:
https://github.com/handlebars-lang/handlebars.js/
Which I use for all my frontend templating needs.
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document); function $(selector, element = document) {
return element.querySelector(selector);
}
function $$(selector, element = document) {
return Array.from(element.querySelectorAll(selector));
}
Reference on more magic available in the console (there’s a lot of good stuff):• https://firefox-source-docs.mozilla.org/devtools-user/web_co... (I think “:help” is my new favourite: opens that URL, which is not particularly discoverable)
• https://developer.chrome.com/docs/devtools/console/utilities...
const $ = (query) => document.querySelector(query);
const $$ = (query) => document.querySelectorAll(query);
(How do I write monospace on HN?)
Two-space indentation.
Thank youhow much is truly saved by this? these seem like the things of a solo dev vs building something for other people to follow
You are talking to me on a site done by one.
This is the frontend code:
… upvote/downvotes are does by fetching an "image", i.e., it does a GET request with side-effects! … also seems like a trivial CSRF vuln, too…