Repository: jazzband/django-debug-toolbar

Issue:
Should jQuery be a dependency ?
Related a few issues, but mainly #535 

Here is [the list of `$` occurences in the source code](http://sprunge.us/fQdh) [1].
- The selectors can be replaced by `.querySelectorAll` and `.querySelector`
- `on()` can be replaced by `addEventListener`
- `cookie()` can be somewhat easily reimplemented
- `removeClass()` can be replaced by `.style.cssText = .style.cssText.replace(/\bClass\b/)`
- `hide()` can be replaced by `.style.display = 'none'`
- `show()` can be replaced by `.style.display = 'initial'`
- `parent()` can be replaced by `.parentNode`
- `.html()` can be replaced by `.innerHTML`
- `.find()` can be replaced by `.querySelectorAll`
- `.text()` can be replaced by `.innerText`
- `.addClass()` can be replaced by `+=  ' Class'`
- `.trigger()` can be replaced by `dispatchEvent()`
- `toggle()` can be replaced by a `.style.display = .style.display === 'none' ? 'initial' : 'none'`
- `is()` is a bit harder to replace, but the selector is always `:visible`, so `.style.display !== 'none'`

etc, etc

Removing jQuery from the dependencies would have multiple benefits :
- No conflict with users environments (which would be great, since it would make the Debug Toolbar a lot less obtrusive)
- A lot less code, and better performances overall (since there is relatively few jQuery use cases in the current codebase)
- No vendors to ship

And the following disadvantages :
- We would have to maintain the very small library which would reimplement jQuery functionalities
- It could break on some browser versions

Overall, I think it would be for the best : the Debug Toolbar is a debug component, and the developers can use a modern browser to use it. Since no client will ever see it, the compatibility issue isn't very relevant.

<hr />

[1]

```
grep -R '\$' /usr/local/lib/python2.7/dist-packages/debug_toolbar/static/debug_toolbar/js/ | grep -Po '\.[a-zA-Z]+\(' | sort | uniq -c | sort -gr
```



Discussion:
This sounds a bit like favoring purity over practicality, but I'm not against taking this path.

(To be honest, I don't feel concerned because I don't intend to touch the JS code much.)

Considering the list above, and the lack of response from other maintainers, I don't feel ready to maintain the JS without jQuery. I can barely maintain it with jQuery.


Resolving patch:
diff --git a/debug_toolbar/panels/sql/utils.py b/debug_toolbar/panels/sql/utils.py
--- a/debug_toolbar/panels/sql/utils.py
+++ b/debug_toolbar/panels/sql/utils.py
@@ -30,8 +30,8 @@ def reformat_sql(sql):
 def swap_fields(sql):
     expr = r'SELECT</strong> (...........*?) <strong>FROM'
     subs = (r'SELECT</strong> '
-            r'<a class="djDebugUncollapsed djDebugToggle" href="#">&#8226;&#8226;&#8226;</a> '
-            r'<a class="djDebugCollapsed djDebugToggle" href="#">\1</a> '
+            r'<span class="djDebugUncollapsed" href="#">&#8226;&#8226;&#8226;</span> '
+            r'<span class="djDebugCollapsed" href="#">\1</span> '
             r'<strong>FROM')
     return re.sub(expr, subs, sql)
 
diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py
--- a/debug_toolbar/settings.py
+++ b/debug_toolbar/settings.py
@@ -17,7 +17,6 @@
     # Toolbar options
     'DISABLE_PANELS': {'debug_toolbar.panels.redirects.RedirectsPanel'},
     'INSERT_BEFORE': '</body>',
-    'JQUERY_URL': '//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js',
     'RENDER_PANELS': None,
     'RESULTS_CACHE_SIZE': 10,
     'ROOT_TAG_EXTRA_ATTRS': '',


Test patch: