refactor: improve js module loading order

This commit is contained in:
Cotes Chung 2024-04-29 03:43:33 +08:00
parent e0950fc973
commit b77767f76e
No known key found for this signature in database
GPG key ID: 0D9E54843167A808
7 changed files with 16 additions and 17 deletions

View file

@ -65,7 +65,7 @@
{% endcase %} {% endcase %}
{% capture script %}{{ js_dist }}{{ js }}.min.js{% endcapture %} {% capture script %}{{ js_dist }}{{ js }}.min.js{% endcapture %}
<script defer src="{{ script | relative_url }}"></script> <script src="{{ script | relative_url }}"></script>
{% if page.math %} {% if page.math %}
<!-- MathJax --> <!-- MathJax -->
@ -88,6 +88,10 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if page.mermaid %}
{% include mermaid.html %}
{% endif %}
{% if jekyll.environment == 'production' %} {% if jekyll.environment == 'production' %}
<!-- PWA --> <!-- PWA -->
{% if site.pwa.enabled %} {% if site.pwa.enabled %}

View file

@ -1,5 +1,5 @@
import { basic, initSidebar, initTopbar } from './modules/layouts'; import { basic, initSidebar, initTopbar } from './modules/layouts';
basic();
initSidebar(); initSidebar();
initTopbar(); initTopbar();
basic();

View file

@ -1,8 +1,8 @@
import { basic, initSidebar, initTopbar } from './modules/layouts'; import { basic, initSidebar, initTopbar } from './modules/layouts';
import { initLocaleDatetime, loadImg } from './modules/plugins'; import { initLocaleDatetime, loadImg } from './modules/plugins';
basic(); loadImg();
initLocaleDatetime();
initSidebar(); initSidebar();
initTopbar(); initTopbar();
initLocaleDatetime(); basic();
loadImg();

View file

@ -1,7 +1,7 @@
import { basic, initSidebar, initTopbar } from './modules/layouts'; import { basic, initSidebar, initTopbar } from './modules/layouts';
import { initLocaleDatetime } from './modules/plugins'; import { initLocaleDatetime } from './modules/plugins';
basic();
initSidebar(); initSidebar();
initTopbar(); initTopbar();
initLocaleDatetime(); initLocaleDatetime();
basic();

View file

@ -1,9 +1,9 @@
import { basic, initSidebar, initTopbar } from './modules/layouts'; import { basic, initSidebar, initTopbar } from './modules/layouts';
import { loadImg, imgPopup, initClipboard } from './modules/plugins'; import { loadImg, imgPopup, initClipboard } from './modules/plugins';
basic();
initSidebar();
initTopbar();
loadImg(); loadImg();
imgPopup(); imgPopup();
initSidebar();
initTopbar();
initClipboard(); initClipboard();
basic();

View file

@ -7,11 +7,11 @@ import {
toc toc
} from './modules/plugins'; } from './modules/plugins';
initSidebar();
initTopbar();
loadImg(); loadImg();
toc();
imgPopup(); imgPopup();
initSidebar();
initLocaleDatetime(); initLocaleDatetime();
initClipboard(); initClipboard();
toc(); initTopbar();
basic(); basic();

View file

@ -75,13 +75,8 @@ layout: compress
{% endif %} {% endif %}
<!-- JavaScripts --> <!-- JavaScripts -->
{% include js-selector.html lang=lang %} {% include js-selector.html lang=lang %}
{% if page.mermaid %}
{% include mermaid.html %}
{% endif %}
{% include_cached search-loader.html lang=lang %} {% include_cached search-loader.html lang=lang %}
</body> </body>
</html> </html>