{"id":17991372,"url":"https://github.com/jareware/el-js","last_synced_at":"2025-08-02T22:05:13.619Z","repository":{"id":57221229,"uuid":"44912859","full_name":"jareware/el-js","owner":"jareware","description":"Utility function for generating HTML/XML DOM trees in the browser.","archived":false,"fork":false,"pushed_at":"2015-11-22T12:01:14.000Z","size":0,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-02T18:36:24.743Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jareware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-25T14:12:26.000Z","updated_at":"2024-02-03T04:51:43.000Z","dependencies_parsed_at":"2022-08-29T02:12:49.712Z","dependency_job_id":null,"html_url":"https://github.com/jareware/el-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jareware/el-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jareware%2Fel-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jareware%2Fel-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jareware%2Fel-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jareware%2Fel-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jareware","download_url":"https://codeload.github.com/jareware/el-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jareware%2Fel-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268464789,"owners_count":24254196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-29T19:21:31.061Z","updated_at":"2025-08-02T22:05:13.527Z","avatar_url":"https://github.com/jareware.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# el-js\n\nUtility function for generating HTML/XML DOM trees in the browser.\n\n## API\n\nThe library exposes a single function, `el()`, which returns [a node](https://developer.mozilla.org/en-US/docs/Web/API/element) with the given name. The rest are var-args, so that:\n\n * an object sets attributes as key/value-pairs\n * a string/number/boolean sets the text content of the node\n * a node is treated as a child node\n * an array is treated as a list of child nodes\n\nFor convenience, [falsy values](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) in the list of children are ignored.\n\nThere's three special cases for the name argument:\n\n * when `\"\"`, a text node is created, with content from the 2nd arg\n * when `\"\u003c!\"`, a comment node is created, with content from the 2nd arg\n * when an existing node, that node is used instead of creating a new one\n\n## Examples\n\nCreating elements, comments and text nodes:\n\n```js\nel('p',\n    el('\u003c!', 'this is a comment'),\n    el('a', 'Click here', {\n        href: '#some-location'\n    }),\n    el('', 'Text after link')\n);\n```\n\nproduces:\n\n```html\n\u003cp\u003e\n    \u003c!--this is a comment--\u003e\n    \u003ca href=\"#some-location\"\u003eClick here\u003c/a\u003e\n    Text after link\n\u003c/p\u003e\n```\n\nMapping arrays into child elements, and filtering by returning falsy values (in this case `undefined`):\n\n```js\nel('ul',\n    [ 1, 2, 3, 4, 5 ].map(function(i) {\n        if (i % 2) return el('li', i);\n    })\n);\n```\n\nproduces:\n\n```html\n\u003cul\u003e\n    \u003cli\u003e1\u003c/li\u003e\n    \u003cli\u003e3\u003c/li\u003e\n    \u003cli\u003e5\u003c/li\u003e\n\u003c/ul\u003e\n```\n\nAppending children into existing elements:\n\n```js\nel(document.querySelector('#existing-root'),\n    el('p', 'New node added under root')\n);\n```\n\nproduces:\n\n```html\n\u003cdiv id=\"existing-root\"\u003e\n    \u003cp\u003ePossible previous content\u003c/p\u003e\n    \u003cp\u003eNew node added under root\u003c/p\u003e\n\u003c/div\u003e\n```\n\n## Acknowledgements\n\nHand-crafted by [@jareware](https://twitter.com/jareware) of [jrw.fi](http://jrw.fi/), with the [loving support](http://futurice.com/blog/sponsoring-free-time-open-source-activities) of [Futurice](http://futurice.com/).\n\n## License\n\n[The MIT license](http://opensource.org/licenses/MIT)\n\n## History\n\nBecause `el-js` is so tiny, it was originally published in 2014 as [just a gist](https://gist.github.com/jareware/8dc0cc1a948c122edce0). This repository and an [npm-presence](https://www.npmjs.com/package/el-js) were added for convenience.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjareware%2Fel-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjareware%2Fel-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjareware%2Fel-js/lists"}