ui: js: Load all JS files in deferred mode to speed up page load

- This improves page rendering time. If JS files are not loaded in deferred or
async mode, they will halt the page rendering until JS files are loaded from
network.

- 'defer' mode guarantees that the load order is same as the order in which JS
files appeared in the HTML page.

Tests:

- Run at least one function of each affected JS file and ensure that is works.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2025-01-04 17:35:45 -08:00 committed by Veiko Aasa
parent ddd2d5b4a3
commit c45bdf56dd
No known key found for this signature in database
GPG Key ID: 478539CAE680674E
11 changed files with 48 additions and 43 deletions

View File

@ -7,6 +7,11 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% block page_js %}
<script type="text/javascript" src="{% static 'dynamicdns/dynamicdns.js' %}"
defer></script>
{% endblock %}
{% block extra_content %} {% block extra_content %}
<h3>{% trans "Status" %}</h3> <h3>{% trans "Status" %}</h3>
@ -52,7 +57,3 @@
{% trans "No status available." %} {% trans "No status available." %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block page_js %}
<script type="text/javascript" src="{% static 'dynamicdns/dynamicdns.js' %}"></script>
{% endblock %}

View File

@ -7,6 +7,11 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% block page_js %}
<script type="text/javascript" src="{% static 'ejabberd/ejabberd.js' %}"
defer></script>
{% endblock %}
{% block status %} {% block status %}
{{ block.super }} {{ block.super }}
@ -30,8 +35,3 @@
</p> </p>
{% endblock %} {% endblock %}
{% block page_js %}
<script type="text/javascript"
src="{% static 'ejabberd/ejabberd.js' %}"></script>
{% endblock %}

View File

@ -6,6 +6,11 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% block page_js %}
<script type="text/javascript" src="{% static 'matrixsynapse/matrixsynapse.js' %}"
defer></script>
{% endblock %}
{% block status %} {% block status %}
{{ block.super }} {{ block.super }}
@ -87,8 +92,3 @@
</div> </div>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block page_js %}
<script type="text/javascript"
src="{% static 'matrixsynapse/matrixsynapse.js' %}"></script>
{% endblock %}

View File

@ -7,5 +7,6 @@
{% load static %} {% load static %}
{% block page_js %} {% block page_js %}
<script type="text/javascript" src="{% static 'mediawiki/mediawiki.js' %}"></script> <script type="text/javascript" src="{% static 'mediawiki/mediawiki.js' %}"
defer></script>
{% endblock %} {% endblock %}

View File

@ -6,6 +6,11 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% block page_js %}
<script type="text/javascript" src="{% static 'networks/networks.js' %}"
defer></script>
{% endblock %}
{% block content %} {% block content %}
<h3>{{ title }}</h3> <h3>{{ title }}</h3>
@ -20,9 +25,3 @@
</form> </form>
{% endblock %} {% endblock %}
{% block page_js %}
<script type="text/javascript" src="{% static 'networks/networks.js' %}"></script>
{% endblock %}

View File

@ -7,6 +7,11 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% block page_js %}
<script type="text/javascript" src="{% static 'sharing/sharing_add_edit.js' %}"
defer></script>
{% endblock %}
{% block content %} {% block content %}
<h3>{{ title }}</h3> <h3>{{ title }}</h3>
@ -21,7 +26,3 @@
</form> </form>
{% endblock %} {% endblock %}
{% block page_js %}
<script type="text/javascript" src="{% static 'sharing/sharing_add_edit.js' %}"></script>
{% endblock %}

View File

@ -7,6 +7,11 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% block page_js %}
<script type="text/javascript" src="{% static 'snapshot/snapshot.js' %}"
defer></script>
{% endblock %}
{% block configuration %} {% block configuration %}
<form class="form" method="post"> <form class="form" method="post">
<div class="button-table"> <div class="button-table">
@ -71,8 +76,3 @@
</div> </div>
</form> </form>
{% endblock %} {% endblock %}
{% block page_js %}
<script type="text/javascript" src="{% static 'snapshot/snapshot.js' %}"></script>
{% endblock %}

View File

@ -7,6 +7,11 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% block page_js %}
<script type="text/javascript" src="{% static 'tor/tor.js' %}"
defer></script>
{% endblock %}
{% block status %} {% block status %}
{{ block.super }} {{ block.super }}
@ -37,7 +42,3 @@
{% block internal_zone %} {% block internal_zone %}
{{ block.super }} {{ block.super }}
{% endblock %} {% endblock %}
{% block page_js %}
<script type="text/javascript" src="{% static 'tor/tor.js' %}"></script>
{% endblock %}

View File

@ -6,5 +6,6 @@
{% load static %} {% load static %}
{% block page_js %} {% block page_js %}
<script type="text/javascript" src="{% static 'torproxy/torproxy.js' %}"></script> <script type="text/javascript" src="{% static 'torproxy/torproxy.js' %}"
defer></script>
{% endblock %} {% endblock %}

View File

@ -7,6 +7,11 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% block page_js %}
<script type="text/javascript" src="{% static 'users/users.js' %}"
defer></script>
{% endblock %}
{% block content %} {% block content %}
<h3> <h3>
{% blocktrans trimmed with username=object.username %} {% blocktrans trimmed with username=object.username %}
@ -67,7 +72,3 @@
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block page_js %}
<script type="text/javascript" src="{% static 'users/users.js' %}"></script>
{% endblock %}

View File

@ -6,6 +6,10 @@
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
{% block page_js %}
<script type="text/javascript" src="{% static 'tags.js' %}" defer></script>
{% endblock %}
{% block body_class %}apps-page{% endblock %} {% block body_class %}apps-page{% endblock %}
{% block tags %} {% block tags %}
@ -46,7 +50,3 @@
</div> </div>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block page_js %}
<script type="text/javascript" src="{% static 'tags.js' %}"></script>
{% endblock %}