Skip to content

Commit 799f585

Browse files
committed
Merge remote-tracking branch 'jdufresne/async'
* jdufresne/async: Load JavaScript resources asynchronously
2 parents 9d29803 + c7382a9 commit 799f585

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

debug_toolbar/static/debug_toolbar/js/toolbar.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
root.querySelectorAll('script').forEach(function(e) {
3030
const clone = document.createElement('script');
3131
clone.src = e.src;
32+
clone.async = true;
3233
root.appendChild(clone);
3334
});
3435
},
@@ -310,5 +311,10 @@
310311
close: djdt.hide_one_level,
311312
cookie: djdt.cookie,
312313
};
313-
document.addEventListener('DOMContentLoaded', djdt.init);
314+
315+
if (document.readyState !== 'loading') {
316+
djdt.init();
317+
} else {
318+
document.addEventListener('DOMContentLoaded', djdt.init);
319+
}
314320
})();

debug_toolbar/templates/debug_toolbar/base.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load i18n %}{% load static %}
22
<link rel="stylesheet" href="{% static 'debug_toolbar/css/print.css' %}" media="print">
33
<link rel="stylesheet" href="{% static 'debug_toolbar/css/toolbar.css' %}">
4-
<script src="{% static 'debug_toolbar/js/toolbar.js' %}" defer></script>
4+
<script src="{% static 'debug_toolbar/js/toolbar.js' %}" async></script>
55
<div id="djDebug" class="djdt-hidden" dir="ltr"
66
{% if toolbar.store_id %}data-store-id="{{ toolbar.store_id }}" data-render-panel-url="{% url 'djdt:render_panel' %}"{% endif %}
77
{{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }}>

debug_toolbar/templates/debug_toolbar/panels/timer.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ <h4>{% trans "Browser timing" %}</h4>
4141
</tbody>
4242
</table>
4343
</div>
44-
<script src="{% static 'debug_toolbar/js/toolbar.timer.js' %}" defer></script>
44+
<script src="{% static 'debug_toolbar/js/toolbar.timer.js' %}" aysnc></script>

debug_toolbar/templates/debug_toolbar/redirect.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<html lang="en">
44
<head>
55
<title>Django Debug Toolbar Redirects Panel: {{ status_line }}</title>
6+
<script src="{% static 'debug_toolbar/js/redirect.js' %}" async></script>
67
</head>
78
<body>
89
<h1>{{ status_line }}</h1>
910
<h2>{% trans "Location:" %} <a id="redirect_to" href="{{ redirect_to }}">{{ redirect_to }}</a></h2>
1011
<p class="notice">
1112
{% trans "The Django Debug Toolbar has intercepted a redirect to the above URL for debug viewing purposes. You can click the above link to continue with the redirect as normal." %}
1213
</p>
13-
<script src="{% static 'debug_toolbar/js/redirect.js' %}" defer></script>
1414
</body>
1515
</html>

0 commit comments

Comments
 (0)