Description
I'm curious if the maintainers would accept pull requests for the following front-end changes. Some of these ideas are more opinionated or need more guidance than my previous PRs, so I wanted to get feedback first.
Remove bower
(#1830/#1832)
bower
As its website says, bower
is maintained but not recommended for use by its developers. Our bower.json
file now only includes two dependencies: jquery
and jquery-flot
.
Instead of using bower
, could we instead put jquery.min.js
and jquery-flot.min.js
directly in djangoproject/static/js/lib/
? This would include removing the jquery
and jquery-flot
directories.
Remove require.js
require.js
had a small security release in July 2024, but the release before that was in 2018, and the project is not under active development. I'm still trying to understand the full influence that require.js
is having on this project, but removing it would require at least the following changes in addition to removing the library itself:
- Remove the setup for
require.js
in thebase.html
template - Remove the
define
calls in our JavaScript modules (example) - Remove or repurpose
main.js
- Option 1: Remove the file and add
<script>
tags to the templates where needed. Adding a new template block for JavaScript includes would also be a good idea. This approach is simple but is riskier and requires more work and testing, but it's the one I would choose. - Option 2: Keep the file for its class-based logic and dynamically add
<script>
tags to the DOM based on it. This approach requires less changes and may be a good way just to removerequire.js
without broader changes.
- Option 1: Remove the file and add
Which approach would be preferred here, or is there a better way than what I presented above?
Remove Boilerplate in Many JavaScript Modules
Many of our JavaScript modules define an enclosing function then add an init
method to its prototype. This is where the actual logic lives. It seems to me that we could decompose these and just run everything in the top-level enclosing function. Perhaps the current pattern is related to require.js
?
Could these modules be simplified, or is this kind of refactor too unnecessary?
Upgrade or Remove jQuery
We're currently using jQuery v1.11.2, and the latest release is v3.7.1. Jumping ahead through ten years of releases could be a pain, but I think it's worth it if jQuery is valued in this project.
Another option would be to remove jQuery
instead. We could convert one module at a time to native browser APIs before its removal. Doing this would probably force a replacement of jquery.flot
for the dashboard
app.
Integrate a JavaScript Linter/Formatter
I'd be willing to work on this, but I'd want guidance on which tool to use and the settings for it.
Thanks for considering these!