{"id":28340543,"url":"https://github.com/homeboy445/scriptorchestrator","last_synced_at":"2025-08-22T10:34:45.727Z","repository":{"id":242127898,"uuid":"805745880","full_name":"homeboy445/ScriptOrchestrator","owner":"homeboy445","description":"JS library for managing scripts on the webpage easily.","archived":false,"fork":false,"pushed_at":"2024-09-22T15:21:59.000Z","size":263,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-27T03:21:19.797Z","etag":null,"topics":["document-object-model","javascript-library","typescript"],"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/homeboy445.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-25T10:45:23.000Z","updated_at":"2024-10-26T17:20:35.000Z","dependencies_parsed_at":"2024-05-31T20:13:26.875Z","dependency_job_id":"8a71a177-c82a-466e-bce2-4503f1098134","html_url":"https://github.com/homeboy445/ScriptOrchestrator","commit_stats":null,"previous_names":["homeboy445/scriptorchestrator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/homeboy445/ScriptOrchestrator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/homeboy445%2FScriptOrchestrator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/homeboy445%2FScriptOrchestrator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/homeboy445%2FScriptOrchestrator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/homeboy445%2FScriptOrchestrator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/homeboy445","download_url":"https://codeload.github.com/homeboy445/ScriptOrchestrator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/homeboy445%2FScriptOrchestrator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261012761,"owners_count":23096914,"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":["document-object-model","javascript-library","typescript"],"created_at":"2025-05-27T03:19:49.893Z","updated_at":"2025-08-22T10:34:45.721Z","avatar_url":"https://github.com/homeboy445.png","language":"JavaScript","readme":"## ScriptOrchestrator: A Powerful Script Manager for Web Browsers\n\n**ScriptOrchestrator** is a JavaScript library designed to simplify and streamline script management within web browsers. It acts as a one-stop solution for loading and executing both inline and external scripts, offering a structured and efficient approach.\n\n### Key Features\n\n* **Sequential Script Loading:** ScriptOrchestrator ensures scripts are loaded and executed in a prioritized order. This prevents conflicts and guarantees scripts are loaded only after their dependencies are met.\n* **Priority Management:** Scripts can be assigned different priority levels (Exceptional, High, Medium, Low) to control their execution order. Exceptional priority scripts execute immediately, while others are loaded based on their assigned priority.\n* **Event-Driven Loading:** Scripts can be configured to load upon specific events triggered within your web application. This allows for dynamic script loading based on user interaction or application state.\n* **Inline and External Script Support:** ScriptOrchestrator handles both inline JavaScript code snippets and external scripts referenced through URLs.\n* **Flexible Script Configuration:** Customize script behavior by attaching attributes and defining timeouts for external scripts.\n\n### Installation\n**ScriptOrchestrator** can be used via a CDN link:\n\n```\nhttps://cdn.jsdelivr.net/gh/homeboy445/ScriptOrchestrator@main/release/bundle.js\n```\n\n### Usage\n\n**ScriptOrchestrator** provides a user-friendly API for managing scripts. Here's a breakdown of its core functionalities:\n\n**1. Initialization:**\n\n```javascript\nconst scriptOrch = require('...'); // For NPM users\n\nconst mainInitConfig = scriptOrch.default();\n```\n\nThis code initializes the ScriptOrchestrator instance and creates a configuration object for script management.\n\n**2. Adding Scripts:**\n\n* **External Script:**\n\n```javascript\nmainInitConfig.scripts.add().src(\"path/to/your/script.js\");\n```\n\nThis adds an external script to the queue, specifying its URL via the `src` method.\n\n* **Inline Script:**\n\n```javascript\nmainInitConfig.scripts.add().inlineCode(\"console.log('Inline Script Executed!')\");\n```\n\nThis adds an inline script containing the provided JavaScript code string using the `inlineCode` method. You can also pass a function as an argument.\n\n**3. Configuring Scripts (Optional):**\n\nThe `add` method allows for additional configuration options:\n\n* `attr`: An object containing HTML attributes to be attached to the script tag.\n* `priority`: A priority level (0: Exceptional, 1: High, 2: Medium, 3: Low) to define the script's execution order.\n* `timeout`: A timeout value (in milliseconds) to specify the waiting time between loading consecutive external scripts.\n\n**4. Attaching Event Listeners (Optional):**\n\nScripts can be configured to trigger event listeners upon specific events:\n\n```javascript\nmainInitConfig.scripts.add().src(\"path/to/your/script.js\").listen(\"load\");\n```\n\nThis attaches a `load` event listener to the script being added. You can customize the event name and optionally define a custom event handler.\n\n**5. Running the ScriptOrchestrator:**\n\n```javascript\nmainInitConfig.run();\n```\n\nThis command initiates the script execution process based on the defined configuration and priority levels.\n\n### Advanced Configuration\n\n* **Stateful Mode:** By default, ScriptOrchestrator maintains an in-memory queue for maintaining the script list. To disable this behavior and avoid storing any data in-memory simply, set the `stateFull` property to `false` during initialization:\n\n```javascript\nconst mainInitConfig = scriptOrch.default({ stateFull: false });\n```\n\n### Usage example\n```\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n    \u003ctitle\u003eDocument\u003c/title\u003e\n    \u003cscript src=\"./dist/bundle.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n        const handler = scriptOrch.default()\n        handler.scripts.add().src(\"URL1\");\n        handler.scripts.add().src(\"URL2\");\n        handler.scripts.add().inlineCode(\"console.log('js code!')\");\n        handler.scripts.add(({ priority: 2 })).src(\"URL3\");\n        handler.run()\n    \u003c/script\u003e\n    \u003c!-- The rest of the page's resources! --\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003eThis is a test page!\u003c/h1\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### API Reference\n\nThis section provides a detailed explanation of the available methods and their parameters:\n\n**1. initializer(config?: { stateFull: boolean })**\n\n* Initializes the ScriptOrchestrator instance.\n* Optional `config` object allows setting the `stateFull` property to `false` for stateless mode.\n* In stateFull mode all the date is stored in memory.\n\n**2. run(reRun?: boolean)**\n\n* Executes the script loading and execution process based on the configured scripts.\n* Optional `reRun` parameter (defaults to `false`) allows re-running previously loaded scripts.\n\n**3. add(config?: { attr?: GenericObject; priority?: LoadPriority; timeout?: number; })**\n\n* Adds a script (either inline or external) to the execution queue.\n* Optional `config` object allows for additional configuration.\n* For passing attributes, simply pass them directly inside the config object.\n* In case you need to use any attributes that are reserved such as priority, timeout, etc. then pass those values inside attr key!\n\n**4. src(srcUrl: string)**\n\n* Used within the `add` method to specify the URL for an external script.\n\n**5. inlineCode(jsCode: string | Function)**\n\n* Used within the `add` method to provide inline JavaScript code\n* Can accept js code as string or a function.\n* In case function is passed as parameter, it will not be accesible globally.\n\n**6. listen(eventName: string, additionalInfo?: { isCustom: boolean })**\n\n* Attaches an event listener to the script being added.\n* `eventName` specifies the event to listen for (e.g., `load`, `error`).\n* Optional `additionalInfo` object allows customization:\n  * `isCustom`: Set to `true` to attach the listener to a custom event handler within ScriptOrchestrator (defaults to attaching to the window object).\n\n**7. Priority Levels:**\n\n* Scripts can be assigned priority levels to control execution order:\n  * **0: Exceptional:** Executes immediately, bypassing the queue.\n  * **1: High:** High priority scripts execute before lower priority ones.\n  * **2: Medium:** Default priority level.\n  * **3: Low:** Lower priority scripts execute after higher priority ones.\n\n**8. Exceptional Priority:**\n\n* Scripts with exceptional priority (value 0) are executed immediately upon adding them, ensuring they run before other scripts regardless of the queue.\n\n### Benefits of Using ScriptOrchestrator\n\n* **Improved Performance:** By prioritizing script loading, you can prevent blocking of critical resources and optimize page load times.\n* **Enhanced Code Organization:** Separate script management promotes cleaner and more maintainable code.\n* **Reduced Complexity:** ScriptOrchestrator simplifies script handling, especially for complex web applications with numerous dependencies.\n* **Increased Flexibility:** Event-driven loading and custom configuration options provide greater control over script behavior.\n\n### Contributing\n\nWe welcome contributions from the open-source community! You can find details on contributing to the ScriptOrchestrator project on the project's GitHub repository (link to be added).\n\n### License\n\nScriptOrchestrator is licensed under the MIT License (see LICENSE file for details).\n\nThis README provides a comprehensive overview of ScriptOrchestrator and its functionalities. We encourage you to explore the library and leverage its capabilities to streamline your web development workflow.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhomeboy445%2Fscriptorchestrator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhomeboy445%2Fscriptorchestrator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhomeboy445%2Fscriptorchestrator/lists"}