Skip to content

Commit 4618f82

Browse files
authored
Merge pull request #1108 from adamchainz/scripts_defer
Use defer attribute on all script tags, remove inline JS
2 parents feafe1d + 0a5e872 commit 4618f82

File tree

10 files changed

+12
-11
lines changed

10 files changed

+12
-11
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
document.getElementById('redirect_to').focus();

debug_toolbar/templates/debug_toolbar/base.html

Lines changed: 1 addition & 1 deletion
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' %}" type="text/css" media="print">
33
<link rel="stylesheet" href="{% static 'debug_toolbar/css/toolbar.css' %}" type="text/css">
4-
<script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script>
4+
<script src="{% static 'debug_toolbar/js/toolbar.js' %}" defer></script>
55
<div id="djDebug" class="djdt-hidden" dir="ltr"
66
{% if toolbar.store_id %}
77
data-store-id="{{ toolbar.store_id }}"

debug_toolbar/templates/debug_toolbar/panels/profiling.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
</tbody>
3434
</table>
3535

36-
<script src="{% static 'debug_toolbar/js/toolbar.profiling.js' %}"></script>
36+
<script src="{% static 'debug_toolbar/js/toolbar.profiling.js' %}" defer></script>

debug_toolbar/templates/debug_toolbar/panels/sql.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@
114114
<p>{% trans "No SQL queries were recorded during this request." %}</p>
115115
{% endif %}
116116

117-
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script>
117+
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}" defer></script>

debug_toolbar/templates/debug_toolbar/panels/sql_explain.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ <h3>{% trans "SQL explained" %}</h3>
3434
</div>
3535
</div>
3636

37-
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script>
37+
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}" defer></script>

debug_toolbar/templates/debug_toolbar/panels/sql_profile.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ <h3>{% trans "SQL profiled" %}</h3>
4141
</div>
4242
</div>
4343

44-
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script>
44+
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}" defer></script>

debug_toolbar/templates/debug_toolbar/panels/sql_select.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ <h3>{% trans "SQL selected" %}</h3>
3838
</div>
3939
</div>
4040

41-
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script>
41+
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}" defer></script>

debug_toolbar/templates/debug_toolbar/panels/timer.html

Lines changed: 1 addition & 1 deletion
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' %}"></script>
44+
<script src="{% static 'debug_toolbar/js/toolbar.timer.js' %}" defer></script>
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% load i18n %}
1+
{% load i18n static %}
22
<!DOCTYPE html>
33
<html>
44
<head>
@@ -9,8 +9,6 @@ <h2>{% trans "Location:" %} <a id="redirect_to" href="{{ redirect_to }}">{{ redi
99
<p class="notice">
1010
{% 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." %}
1111
</p>
12-
<script type="text/javascript">
13-
document.getElementById('redirect_to').focus();
14-
</script>
12+
<script src="{% static 'debug_toolbar/js/redirect.js' %}" defer></script>
1513
</body>
1614
</html>

docs/changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Change log
44
UNRELEASED
55
----------
66

7+
* Use ``defer`` on all ``<script>`` tags to avoid blocking HTML parsing.
8+
79
1.10.1 (2018-09-11)
810
-------------------
911

0 commit comments

Comments
 (0)