Skip to content

Use defer attribute on all script tags, remove inline JS #1108

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

Merged
merged 3 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions debug_toolbar/static/debug_toolbar/js/redirect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
document.getElementById('redirect_to').focus();
2 changes: 1 addition & 1 deletion debug_toolbar/templates/debug_toolbar/base.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% load i18n %}{% load static %}
<link rel="stylesheet" href="{% static 'debug_toolbar/css/print.css' %}" type="text/css" media="print">
<link rel="stylesheet" href="{% static 'debug_toolbar/css/toolbar.css' %}" type="text/css">
<script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script>
<script src="{% static 'debug_toolbar/js/toolbar.js' %}" defer></script>
<div id="djDebug" class="djdt-hidden" dir="ltr"
{% if toolbar.store_id %}
data-store-id="{{ toolbar.store_id }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
</tbody>
</table>

<script src="{% static 'debug_toolbar/js/toolbar.profiling.js' %}"></script>
<script src="{% static 'debug_toolbar/js/toolbar.profiling.js' %}" defer></script>
2 changes: 1 addition & 1 deletion debug_toolbar/templates/debug_toolbar/panels/sql.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@
<p>{% trans "No SQL queries were recorded during this request." %}</p>
{% endif %}

<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script>
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}" defer></script>
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ <h3>{% trans "SQL explained" %}</h3>
</div>
</div>

<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script>
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}" defer></script>
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ <h3>{% trans "SQL profiled" %}</h3>
</div>
</div>

<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script>
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}" defer></script>
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ <h3>{% trans "SQL selected" %}</h3>
</div>
</div>

<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script>
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}" defer></script>
2 changes: 1 addition & 1 deletion debug_toolbar/templates/debug_toolbar/panels/timer.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ <h4>{% trans "Browser timing" %}</h4>
</tbody>
</table>
</div>
<script src="{% static 'debug_toolbar/js/toolbar.timer.js' %}"></script>
<script src="{% static 'debug_toolbar/js/toolbar.timer.js' %}" defer></script>
6 changes: 2 additions & 4 deletions debug_toolbar/templates/debug_toolbar/redirect.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load i18n %}
{% load i18n static %}
<!DOCTYPE html>
<html>
<head>
Expand All @@ -9,8 +9,6 @@ <h2>{% trans "Location:" %} <a id="redirect_to" href="{{ redirect_to }}">{{ redi
<p class="notice">
{% 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." %}
</p>
<script type="text/javascript">
document.getElementById('redirect_to').focus();
</script>
<script src="{% static 'debug_toolbar/js/redirect.js' %}" defer></script>
</body>
</html>
2 changes: 2 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Change log
UNRELEASED
----------

* Use ``defer`` on all ``<script>`` tags to avoid blocking HTML parsing.

1.10.1 (2018-09-11)
-------------------

Expand Down