{"id":21916892,"url":"https://github.com/zenoo/react-append-head","last_synced_at":"2025-04-19T03:20:39.654Z","repository":{"id":35140975,"uuid":"209024733","full_name":"Zenoo/react-append-head","owner":"Zenoo","description":"Append JS \u0026 CSS files to the document's head without duplicates","archived":false,"fork":false,"pushed_at":"2022-12-04T12:17:11.000Z","size":644,"stargazers_count":5,"open_issues_count":7,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T06:43:23.199Z","etag":null,"topics":["react","script"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/Zenoo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-17T10:27:10.000Z","updated_at":"2021-11-08T21:36:46.000Z","dependencies_parsed_at":"2023-01-15T14:38:56.371Z","dependency_job_id":null,"html_url":"https://github.com/Zenoo/react-append-head","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zenoo%2Freact-append-head","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zenoo%2Freact-append-head/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zenoo%2Freact-append-head/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zenoo%2Freact-append-head/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zenoo","download_url":"https://codeload.github.com/Zenoo/react-append-head/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249598462,"owners_count":21297464,"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","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":["react","script"],"created_at":"2024-11-28T19:21:28.648Z","updated_at":"2025-04-19T03:20:39.633Z","avatar_url":"https://github.com/Zenoo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-append-head\n\nIf your react components ever need to add tags to your app's `\u003chead\u003e` section, this is the component for you !  \n\n## AppendHead\n\nYou can use AppendHead inside any React app:\n\n```jsx\nimport React from 'react';\nimport AppendHead from 'react-append-head';\n\nclass Alert extends React.Component {\n  constructor(props) {\n    super(props);\n  }\n\n  render() {\n    return (\n      \u003cdiv className='alert alert-warning alert-dismissible' role=\"alert\"\u003e\n        \u003cAppendHead\u003e\n          \u003clink name=\"bootstrap\" rel=\"stylesheet\" href=\"libs/bootstrap/css/bootstrap.min.css\"\u003e\n          \u003cscript name='jquery' src='libs/jquery/dist/jquery.min.js' order=\"0\"\u003e\u003c/script\u003e\n          \u003cscript name='bootstrap-alert' src='libs/bootstrap/js/dist/alert.js' order=\"1\"\u003e\u003c/script\u003e\n        \u003c/AppendHead\u003e\n        {this.props.children}\n      \u003c/div\u003e\n    );\n  }\n}\n```\n\nAny direct child inside the `AppendHead` component will be transferred to the app's `\u003chead\u003e` section.\n\n## Script duplicates\n\nEvery script/stylesheet must have a `name` attribute.  \nIt is used to avoid loading the same script multiple times.  \nOnly the first combination of script/name or stylesheet/name will be imported.\n\nExample: \n\n```html\n\u003c!-- First occurence of a stylesheet named `bootstrap` : OK --\u003e\n\u003clink name=\"bootstrap\" rel=\"stylesheet\" href=\"style.css\"\u003e\n\u003c!-- First occurence of a script named `jquery` : OK --\u003e\n\u003cscript name='jquery' src='jquery.min.js'\u003e\u003c/script\u003e\n\u003c!-- First occurence of a script named `bootsrap` : OK --\u003e\n\u003cscript name='bootstrap' src='bootstrap.min.js'\u003e\u003c/script\u003e\n\u003c!-- Second occurence of a script named `bootsrap` : NOT IMPORTED --\u003e\n\u003cscript name='bootstrap' src='bootstrap2.min.js'\u003e\u003c/script\u003e\n```\n\n## Loading script dependencies\n\nIf you need to load scripts in specific order, simply add the attribute `order` to your scripts, they will be loaded from the lowest to the highest.  \nIf you don't specify the `order` attribute, the script will start loading asynchronously, as soon as possible.\n\nExample: \n\n```html\n\u003c!-- The `order` attribute present, this script will be loaded first --\u003e\n\u003cscript name='jquery' src='jquery.min.js' order=\"0\"\u003e\u003c/script\u003e\n\u003c!-- The `order` attribute is not present, this script will be loaded without waiting for any other --\u003e\n\u003cscript name='whatever' src='whatever.min.js'\u003e\u003c/script\u003e\n\u003c!-- The `order` attribute is present, this script will be loaded after every other script with an order lower than him --\u003e\n\u003cscript name='bootstrap' src='bootstrap.min.js' order=\"1\"\u003e\u003c/script\u003e\n```\n\n## onLoad\n\nYou can add a callback via the `onLoad` prop on `AppendHead` to execute some code after every queued ressource has been loaded.\n\n```jsx\n\u003cAppendHead onLoad={...}\u003e\n  ...\n\u003c/AppendHead\u003e\n```\n\n## Debug\n\nYou can add the `debug` prop to `AppendHead` to see what's going on in the console.\n\n```jsx\n\u003cAppendHead debug\u003e\n  ...\n\u003c/AppendHead\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenoo%2Freact-append-head","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenoo%2Freact-append-head","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenoo%2Freact-append-head/lists"}