https://github.com/onehilltech/ember-cli-script
An EmberJS add-on for dynamically loading scripts
https://github.com/onehilltech/ember-cli-script
Last synced: about 1 month ago
JSON representation
An EmberJS add-on for dynamically loading scripts
- Host: GitHub
- URL: https://github.com/onehilltech/ember-cli-script
- Owner: onehilltech
- License: apache-2.0
- Created: 2022-10-27T00:14:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-27T00:15:47.000Z (over 2 years ago)
- Last Synced: 2025-02-27T05:07:29.401Z (2 months ago)
- Language: JavaScript
- Size: 463 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
ember-cli-script
==============================================================================An EmberJS add-on for dynamically loading scripts
Compatibility
------------------------------------------------------------------------------* Ember.js v3.24 or above
* Ember CLI v3.24 or above
* Node.js v12 or aboveInstallation
------------------------------------------------------------------------------```
ember install ember-cli-script
```Usage
------------------------------------------------------------------------------First, inject the `script` service into the corresponding EmberJS entity. Then,
call the `script.load(src)` method. If the script has not been loaded into the
document, then it will be loaded. If it has been loaded, then the currently loaded
script is used.```javascript
import { inject as service } from '@ember/service';export default SomeService extends Service {
@service
script;
constructor () {
super (...arguments);
this.script.load ('https://cdn.somescript.com').then (script => {
// The script has been loaded. We can now use it contents.
});
}
}
```### Reason for this add-on
This add-on is intended to be used within applications and add-ons that need
to control when and how a script is dynamically loaded. It is an alternative
to using the `` tag.```html
<script src="https://cdn.somescript.com" async defer />
```Contributing
------------------------------------------------------------------------------See the [Contributing](CONTRIBUTING.md) guide for details.
License
------------------------------------------------------------------------------This project is licensed under the [MIT License](LICENSE.md).