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:
Juro Oravec 2024-12-06 08:22:27 +01:00 committed by GitHub
parent e88e3af27f
commit be27c1c94d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 833 additions and 379 deletions

View file

@ -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.