{"id":23673927,"url":"https://github.com/nicholaswmin/dom","last_synced_at":"2026-01-26T01:32:36.328Z","repository":{"id":269102280,"uuid":"906428498","full_name":"nicholaswmin/dom","owner":"nicholaswmin","description":"fluent DOM in ~400 bytes","archived":false,"fork":false,"pushed_at":"2024-12-22T16:32:14.000Z","size":52,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-06T20:56:07.235Z","etag":null,"topics":["dom","dom-api","fluent-api"],"latest_commit_sha":null,"homepage":"https://nicholaswmin.github.io/dom/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicholaswmin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-20T22:23:57.000Z","updated_at":"2024-12-22T16:32:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"97b8c1ac-f75f-490e-ac92-0206ac737d28","html_url":"https://github.com/nicholaswmin/dom","commit_stats":null,"previous_names":["nicholaswmin/dom"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nicholaswmin/dom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaswmin%2Fdom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaswmin%2Fdom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaswmin%2Fdom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaswmin%2Fdom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicholaswmin","download_url":"https://codeload.github.com/nicholaswmin/dom/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaswmin%2Fdom/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28763937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T00:37:26.264Z","status":"ssl_error","status_checked_at":"2026-01-26T00:37:25.959Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dom","dom-api","fluent-api"],"created_at":"2024-12-29T12:57:39.136Z","updated_at":"2026-01-26T01:32:36.312Z","avatar_url":"https://github.com/nicholaswmin.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![test-workflow][test-badge]][test-workflow]\n\n## `dom`\n\n\u003e concise [DOM api][dom-api] in `~ 400 bytes`\n\n\u003ca href=\"https://nicholaswmin.github.io/dom\"\u003e\n  \u003cimg width=\"700px\" \n    alt=\"code snippet showing a usage example\" \n    src=\"https://github.com/user-attachments/assets/2e5fac8c-70f4-43e1-b1f4-e9203e32b307\"\u003e\n  \u003c/img\u003e\n\u003c/a\u003e\n\n\n- concise selectors: `$('.foobar')`\n- concise event methods: `.on('event', fn)` / `.off('event', fn)`\n- an additional `css(..)` method.\n- [method-chaining][fluent-api]\n\n## todo\n\n- [x] fix CI tests\n- [x] fix event tests\n- [x] add a carbon snippet here\n- [ ] snippetify that code thing\n\n## rationale\n\nI often hack up short HTML sandboxes for testing a component I'm working on.   \nThese boilerplate files are best kept *stupidly-simple* \nso as not to distract from the actual component itself. In other words: \ndont use a framework.\n\nHowever, the native DOM API is annoyingly verbose even for the simplest of\ntasks, which ends up cluttering the file in and by itself.    \n\nErgo, this.  \n\nThe 3 methods covered here replace common but unbearably verbose \nDOM API methods with consice, chainable equivalents.   \n\nIt doesn't cover everything but that's by design:   \nIt's small API surface means there's nothing to memorise, \nit's impossible to break \u0026 straightforward to understand,\neven if you've never read a single word of this document.\n\nYes, it's like jQuery.\n\n## usage\n\ndrop this:\n\n```html\n\u003cscript type=\"module\" src=\"https://cdn.jsdelivr.net/gh/nicholaswmin/dom@main/dom.js\"\u003e\u003c/script\u003e\n```\n\nor just copy/paste the [source](./dom.js) in your own project. \n\nI use it as an editor code-snippet.\n\n## api\n\nselecting elements:\n\n```js\n$.$$('div') // select all divs\n$.$('div') // select first matching\n```\n\nstyle props:\n\n```js\n$.$$('div').css({ background: 'red' })  \n// all divs are now red\n```\n\nevent listeners:\n\n```js\nc.on('click', function(e) {\n  this.css({ color: 'red', cursor: 'pointer' })\n  // set styles\n})\n.on('mouseover', function(e) {\n  // is chainable\n})\n.css({ color: 'black' })\n```\n\nremove listeners:\n\n```js\n// remove all click listeners\n$.$$('div').off('click')\n\n// remove all listeners, for all divs\n$.$$('div').off()\n```\n\nactual DOM elements:\n\n```js\n// actual DOM element\n$.$('div').$ \n\n// actual DOM elements\n$.$$('div').$$ \n\n// example\n$.$('div').$.textContent = 'hello world'\n```\n\n\n## tests\n\n```bash\nnode --import ./test/setup.js --test\n```\n\n\u003e [!note]  \n\u003e requires: node `v22+`\n\n## misc\n\n\u003e serve demo\n\n```bash\nnpx serve\n```\n\n## license\n\n\u003e [ISC License][isc]\n\u003e\n\u003e @nicholaswmin, 2024\n\u003e\n\u003e Permission to use, copy, modify, and/or distribute or resell this software \n\u003e for *any purpose* is hereby granted *without fee*, provided that the above \n\u003e copyright notice and this permission notice appear in all copies.\n\n[test-badge]: https://github.com/nicholaswmin/dom/actions/workflows/test.yml/badge.svg\n[test-workflow]: https://github.com/nicholaswmin/dom/actions/workflows/test.yml\n[website]: https://nicholaswmin.github.io/dom\n[nicholaswmin]: https://githhub.com/nicholaswmin\n[fluent-api]: https://en.wikipedia.org/wiki/Method_chaining\n[ignore]: https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer\n[dom-api]: https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction\n[isc]: https://spdx.org/licenses/ISC.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholaswmin%2Fdom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicholaswmin%2Fdom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholaswmin%2Fdom/lists"}