{"id":15982613,"url":"https://github.com/seanmcp/vanilla-include","last_synced_at":"2026-06-20T04:31:23.314Z","repository":{"id":57390677,"uuid":"147852300","full_name":"SeanMcP/vanilla-include","owner":"SeanMcP","description":"A JavaScript implementation of php's include function for HTML templating","archived":false,"fork":false,"pushed_at":"2018-09-11T11:13:23.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-06T13:50:42.204Z","etag":null,"topics":["html-template","include","javascript","npm","npm-package","vanilla-javascript"],"latest_commit_sha":null,"homepage":null,"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/SeanMcP.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":"2018-09-07T17:03:44.000Z","updated_at":"2023-04-11T15:23:59.000Z","dependencies_parsed_at":"2022-09-01T16:02:32.643Z","dependency_job_id":null,"html_url":"https://github.com/SeanMcP/vanilla-include","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SeanMcP/vanilla-include","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeanMcP%2Fvanilla-include","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeanMcP%2Fvanilla-include/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeanMcP%2Fvanilla-include/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeanMcP%2Fvanilla-include/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeanMcP","download_url":"https://codeload.github.com/SeanMcP/vanilla-include/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeanMcP%2Fvanilla-include/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270080169,"owners_count":24523667,"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-12T02:00:09.011Z","response_time":80,"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":["html-template","include","javascript","npm","npm-package","vanilla-javascript"],"created_at":"2024-10-08T01:20:31.928Z","updated_at":"2026-06-20T04:31:23.278Z","avatar_url":"https://github.com/SeanMcP.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vanilla-include\n\n[![npm](https://img.shields.io/npm/v/vanilla-include.svg)](https://npmjs.com/package/vanilla-include) [![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/vanilla-include.svg)](https://npmjs.com/package/vanilla-include) [![npm](https://img.shields.io/npm/dt/vanilla-include.svg)](https://npmjs.com/package/vanilla-include)\n\nA JavaScript implementation of php's include function for HTML templating.\n\n## Why?\n\nphp's `include` function is incredibly useful for simple HTML templating. This library seeks to implement a similar functionality with just vanilla JavaScript.\n\n## Install\n\nGet CDN from [UNPKG](https://unpkg.com):\n\n```\n\u003cscript src=\"https://unpkg.com/vanilla-include\"\u003e\u003c/script\u003e\n```\n\nInstall via npm or yarn:\n\n```sh\nnpm install --save vanilla-include\n\n# or\n\nyarn add vanilla-include\n```\n\n## Docs\n\n### Basic\n\nWhen your document loads, `vanilla-include` will look for all elements that have a `data-include` attribute and **replace** them with the target HTML file.\n\n#### 1. Create your file to include\n\n```\n\u003c!-- path/to/file.html --\u003e\n\n\u003ch1\u003eHello from vanilla-include!\u003c/h1\u003e\n```\n\n#### 2. Add `vanilla-include` and refer to file with `data-include` attribute\n\n```\n\u003c!-- index.html --\u003e\n\n\u003cbody\u003e\n    \u003cbr data-include=\"path/to/file.html\"\u003e\n\u003c/body\u003e\n...\n\u003cscript src=\"vanilla-include.min.js\"\u003e\u003c/script\u003e\n```\n\n#### 3. Voila!\n\n`index.html` will render like so:\n\n```\n\u003cbody\u003e\n    \u003ch1\u003eHello from vanilla-include!\u003c/h1\u003e\n\u003c/body\u003e\n```\n\n### Details\n\nThe `data-include` attribute can be added to any element in your document. That means you can use `vanilla-include` to add things like `\u003ctitle\u003e` or `\u003cmeta\u003e` tags.\n\nIn practice, the `\u003cbr\u003e` tag is useful because it is both short and self-closing, but you can use whatever tag best fits your scenario.\n\nShould the resource fail to load, `vanilla-include` will fail \"silently\" by setting the element's `display` style to `none`.\n\n## License\n\n[MIT](https://github.com/seanmcp/vanilla-include/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseanmcp%2Fvanilla-include","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseanmcp%2Fvanilla-include","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseanmcp%2Fvanilla-include/lists"}