mirror of
https://github.com/django-components/django-components.git
synced 2025-08-10 01:08:00 +00:00
fix: Fix broken JS execution order (#821)
* fix: fix broken js exec order * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor: remove stale comment --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
e88e3af27f
commit
be27c1c94d
15 changed files with 833 additions and 379 deletions
|
@ -189,15 +189,15 @@ This is how we achieve that:
|
|||
|
||||
```js
|
||||
// Load JS or CSS script if not loaded already
|
||||
Components.loadScript("js", '<script src="/abc/xyz/script.js">');
|
||||
Components.loadScript("css", '<link href="/abc/xyz/style.css">');
|
||||
Components.loadJs('<script src="/abc/xyz/script.js">');
|
||||
Components.loadCss('<link href="/abc/xyz/style.css">');
|
||||
|
||||
// Or mark one as already-loaded, so it is ignored when
|
||||
// we call `loadScript`
|
||||
// we call `loadJs`
|
||||
Components.markScriptLoaded("js", "/abc/def");
|
||||
```
|
||||
|
||||
Note that `loadScript()` receives a whole `<script>` and `<link>` tags, not just the URL.
|
||||
Note that `loadJs() / loadCss()` receive whole `<script> / <link>` tags, not just the URL.
|
||||
This is because when Django's `Media` class renders JS and CSS, it formats it as `<script>` and `<link>` tags.
|
||||
And we allow users to modify how the JS and CSS should be rendered into the `<script>` and `<link>` tags.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue