Skip to content

Commit

Permalink
refactor: improve js module loading order
Browse files Browse the repository at this point in the history
  • Loading branch information
cotes2020 committed Apr 28, 2024
1 parent d6461d0 commit 0d11266
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
6 changes: 5 additions & 1 deletion _includes/js-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
{% endcase %}

{% capture script %}{{ js_dist }}{{ js }}.min.js{% endcapture %}
<script defer src="{{ script | relative_url }}"></script>
<script src="{{ script | relative_url }}"></script>

{% if page.math %}
<!-- MathJax -->
Expand All @@ -88,6 +88,10 @@
{% endif %}
{% endif %}

{% if page.mermaid %}
{% include mermaid.html %}
{% endif %}

{% if jekyll.environment == 'production' %}
<!-- PWA -->
{% if site.pwa.enabled %}
Expand Down
2 changes: 1 addition & 1 deletion _javascript/commons.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { basic, initSidebar, initTopbar } from './modules/layouts';

basic();
initSidebar();
initTopbar();
basic();
6 changes: 3 additions & 3 deletions _javascript/home.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { basic, initSidebar, initTopbar } from './modules/layouts';
import { initLocaleDatetime, loadImg } from './modules/plugins';

basic();
loadImg();
initLocaleDatetime();
initSidebar();
initTopbar();
initLocaleDatetime();
loadImg();
basic();
2 changes: 1 addition & 1 deletion _javascript/misc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { basic, initSidebar, initTopbar } from './modules/layouts';
import { initLocaleDatetime } from './modules/plugins';

basic();
initSidebar();
initTopbar();
initLocaleDatetime();
basic();
6 changes: 3 additions & 3 deletions _javascript/page.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { basic, initSidebar, initTopbar } from './modules/layouts';
import { loadImg, imgPopup, initClipboard } from './modules/plugins';

basic();
initSidebar();
initTopbar();
loadImg();
imgPopup();
initSidebar();
initTopbar();
initClipboard();
basic();
6 changes: 3 additions & 3 deletions _javascript/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
toc
} from './modules/plugins';

initSidebar();
initTopbar();
loadImg();
toc();
imgPopup();
initSidebar();
initLocaleDatetime();
initClipboard();
toc();
initTopbar();
basic();
5 changes: 0 additions & 5 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,8 @@
{% endif %}

<!-- JavaScripts -->

{% include js-selector.html lang=lang %}

{% if page.mermaid %}
{% include mermaid.html %}
{% endif %}

{% include_cached search-loader.html lang=lang %}
</body>
</html>

0 comments on commit 0d11266

Please sign in to comment.