mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Load scripts using defer in <head> (#882)
This commit is contained in:
parent
fd3852602f
commit
69e0dbdeea
@ -5,6 +5,11 @@
|
||||
{%- include '_partials/head/head-unique.njk' -%}
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
{{ partial('_third-party/analytics/index.njk', {}, {cache: theme.cache.enable}) }}
|
||||
{{ partial('_scripts/index.njk', {}, {cache: theme.cache.enable}) }}
|
||||
{{ partial('_third-party/index.njk', {}, {cache: theme.cache.enable}) }}
|
||||
{{ partial('_third-party/statistics/index.njk', {}, {cache: theme.cache.enable}) }}
|
||||
{%- include '_third-party/math/index.njk' -%}
|
||||
{%- include '_third-party/quicklink.njk' -%}
|
||||
{{- next_inject('head') }}
|
||||
<noscript>
|
||||
<link rel="stylesheet" href="{{ url_for(theme.css) }}/noscript.css">
|
||||
@ -40,13 +45,6 @@
|
||||
|
||||
{{ partial('_partials/widgets.njk', {}, {cache: theme.cache.enable}) }}
|
||||
|
||||
{{ partial('_scripts/index.njk', {}, {cache: theme.cache.enable}) }}
|
||||
{{ partial('_third-party/index.njk', {}, {cache: theme.cache.enable}) }}
|
||||
{{ partial('_third-party/statistics/index.njk', {}, {cache: theme.cache.enable}) }}
|
||||
|
||||
{%- include '_third-party/math/index.njk' -%}
|
||||
{%- include '_third-party/quicklink.njk' -%}
|
||||
|
||||
{{- next_inject('bodyEnd') }}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{%- if theme.canvas_ribbon.enable %}
|
||||
<script size="{{ theme.canvas_ribbon.size }}" alpha="{{ theme.canvas_ribbon.alpha }}" zIndex="{{ theme.canvas_ribbon.zIndex }}" src="{{ theme.vendors.canvas_ribbon.url }}"></script>
|
||||
<script size="{{ theme.canvas_ribbon.size }}" alpha="{{ theme.canvas_ribbon.alpha }}" zIndex="{{ theme.canvas_ribbon.zIndex }}" src="{{ theme.vendors.canvas_ribbon.url }}" defer></script>
|
||||
{%- endif %}
|
||||
|
||||
{%- for name in js_vendors() %}
|
||||
|
||||
@ -32,7 +32,7 @@ hexo.extend.helper.register('next_js', function(file, {
|
||||
custom : custom_cdn_url
|
||||
});
|
||||
const src = links[internal] || links.local;
|
||||
return `<script ${pjax ? 'data-pjax ' : ''}${module ? 'type="module" ' : ''}src="${src}"></script>`;
|
||||
return `<script ${pjax ? 'data-pjax ' : ''}${module ? 'type="module" ' : ''}src="${src}" defer></script>`;
|
||||
});
|
||||
|
||||
hexo.extend.helper.register('next_vendors', function(name) {
|
||||
@ -42,8 +42,8 @@ hexo.extend.helper.register('next_vendors', function(name) {
|
||||
if (integrity) return `<link rel="stylesheet" href="${url}" integrity="${integrity}" crossorigin="anonymous">`;
|
||||
return `<link rel="stylesheet" href="${url}">`;
|
||||
}
|
||||
if (integrity) return `<script src="${url}" integrity="${integrity}" crossorigin="anonymous"></script>`;
|
||||
return `<script src="${url}"></script>`;
|
||||
if (integrity) return `<script src="${url}" integrity="${integrity}" crossorigin="anonymous" defer></script>`;
|
||||
return `<script src="${url}" defer></script>`;
|
||||
});
|
||||
|
||||
hexo.extend.helper.register('next_data', function(name, ...data) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user