Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor JavaScript inclusion #1277

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Refactor JavaScript inclusion #1277

wants to merge 10 commits into from

Conversation

koeaw
Copy link
Contributor

@koeaw koeaw commented Oct 9, 2024

Moves (most of) the existing internal JS to external files in an attempt to solve #1166.

Event listening for loading of static content is implemented via readystatechange rather than DOMContentLoaded or load to allow for greater flexibility, also with regard to integrating jQuery (which does its own thing).

The remaining internal JS is in apis_relations. The last commit reformats abstractentity_form.html for readability.

Tangentially related: the internal JS was recently moved from apis_entities to apis_relations. It interacts with functions in apis_entities.js, which should probably be moved to apis_relations.js in apis_relations (?!).

koeaw added 4 commits October 9, 2024 11:28
Move <script> tag which embeds external Bootstrap 4
bundle from included partial template directly into
base.html, place it before bootstrap-multiselect
dependency, and remove partial.
Move <script> tag which embeds external HTMX
package from script block at bottom of base.html
template to block at top of file; add attributes
for subresource integrity and CORS.
Add event listener for readystatechange
to core.js.
Move jQuery config for multiselect widget to
own function, drop $(document).ready() wrapper
in favour of vanilla JS event listener,
update comments.
@koeaw koeaw force-pushed the kk/refactor/inline_js branch from 47690ee to 935d5b1 Compare October 9, 2024 10:04
koeaw added 5 commits October 9, 2024 12:09
Move event listener for XHTM swapping from
internal script in base.html to external core.js
file.
Add to, update formatting of existing comments
on HTMX swap config.
Move internal script from included partial
template backtotopbtn.html to external core.js
file.
Improve wording, formatting of existing comments
on scroll button JavaScript.
Set defer attribute on script tags for external
scripts.
@koeaw koeaw force-pushed the kk/refactor/inline_js branch from 935d5b1 to 13ba98b Compare October 9, 2024 10:13
Reformat JavaScript in <script> tag mixed with
template language syntax for readability.
Includes conversion of comments formatted for
JavaScript to Django template syntax.
@koeaw koeaw force-pushed the kk/refactor/inline_js branch from c42f361 to 8a890b9 Compare October 9, 2024 10:55
@koeaw koeaw changed the title Refactor JavaScript (inclusion) Refactor JavaScript inclusion Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant