mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Use minified js files for jsdelivr and cdnjs (#207)
This commit is contained in:
parent
538b06c7e8
commit
44b0d08a41
@ -18,11 +18,12 @@ hexo.extend.helper.register('next_inject', function(point) {
|
||||
hexo.extend.helper.register('next_js', function(file, pjax = false) {
|
||||
const { next_version } = this;
|
||||
const { internal } = this.theme.vendors;
|
||||
const minified_file = file.endsWith('.js') && !file.endsWith('.min.js') ? file.slice(0, -3) + '.min.js' : file;
|
||||
const links = {
|
||||
local : this.url_for(`${this.theme.js}/${file}`),
|
||||
jsdelivr: `https://cdn.jsdelivr.net/npm/hexo-theme-next@${next_version}/source/js/${file}`,
|
||||
jsdelivr: `https://cdn.jsdelivr.net/npm/hexo-theme-next@${next_version}/source/js/${minified_file}`,
|
||||
unpkg : `https://unpkg.com/hexo-theme-next@${next_version}/source/js/${file}`,
|
||||
cdnjs : `https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-next/${next_version}/${file}`
|
||||
cdnjs : `https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-next/${next_version}/${minified_file}`
|
||||
};
|
||||
const src = links[internal] || links.local;
|
||||
return `<script ${pjax ? 'data-pjax ' : ''}src="${src}"></script>`;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user