mirror of
https://github.com/Colin-XKL/Colinx-Blog.git
synced 2026-01-11 02:01:29 +08:00
feat: optimize script loading using onload event
This commit is contained in:
@@ -7,34 +7,35 @@
|
||||
if (meta) meta.innerHTML = meta.innerHTML + visitors
|
||||
</script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.11.1/tocbot.min.js"></script>
|
||||
<script >
|
||||
tocbot.init({
|
||||
// Where to render the table of contents.
|
||||
tocSelector: '.js-toc',
|
||||
// Where to grab the headings to build the table of contents.
|
||||
contentSelector: '.post-content',
|
||||
// Which headings to grab inside of the contentSelector element.
|
||||
headingSelector: 'h1, h2, h3',
|
||||
// For headings inside relative or absolute positioned containers within content.
|
||||
hasInnerContainers: true,
|
||||
});
|
||||
<script>
|
||||
function tocbot_init() {
|
||||
tocbot.init({
|
||||
// Where to render the table of contents.
|
||||
tocSelector: '.js-toc',
|
||||
// Where to grab the headings to build the table of contents.
|
||||
contentSelector: '.post-content',
|
||||
// Which headings to grab inside of the contentSelector element.
|
||||
headingSelector: 'h1, h2, h3',
|
||||
// For headings inside relative or absolute positioned containers within content.
|
||||
hasInnerContainers: true,
|
||||
});
|
||||
}
|
||||
function init_gitalk() {
|
||||
const gitalk = new Gitalk({
|
||||
clientID: '94eae56b89dcc480bf4d',
|
||||
clientSecret: '1e4218c0293a998a9483ab09ba9ace46cabc76b3',
|
||||
repo: 'Colinx-Blog', // The repository of store comments,
|
||||
owner: 'Colin-XKL',
|
||||
admin: ['Colin-XKL'],
|
||||
id: decodeURI(location.pathname), // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false // Facebook-like distraction free mode
|
||||
});
|
||||
gitalk.render('gitalk-container');
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.11.1/tocbot.css">
|
||||
|
||||
<script defer src="{{ "assets/prism.js" | absURL }}"></script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
|
||||
<script >
|
||||
const gitalk = new Gitalk({
|
||||
clientID: '94eae56b89dcc480bf4d',
|
||||
clientSecret: '1e4218c0293a998a9483ab09ba9ace46cabc76b3',
|
||||
repo: 'Colinx-Blog', // The repository of store comments,
|
||||
owner: 'Colin-XKL',
|
||||
admin: ['Colin-XKL'],
|
||||
id: decodeURI(location.pathname), // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false // Facebook-like distraction free mode
|
||||
});
|
||||
gitalk.render('gitalk-container');
|
||||
</script>
|
||||
<script defer onload="tocbot_init()" src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.11.1/tocbot.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.11.1/tocbot.css">
|
||||
<script defer onload="init_gitalk()" src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">
|
||||
@@ -1,12 +1,14 @@
|
||||
<script src="{{ "assets/main.js" | absURL }}"></script>
|
||||
<script async src="{{ " assets/main.js" | absURL }}"></script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js"></script>
|
||||
<script >
|
||||
pangu.spacingElementByClassName('post');
|
||||
pangu.spacingElementByTagName('p');
|
||||
<script>
|
||||
function panguSpaing() {
|
||||
pangu.spacingElementByClassName('post');
|
||||
pangu.spacingElementByTagName('p');
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// listen to any DOM change and automatically perform spacing via MutationObserver()
|
||||
pangu.autoSpacingPage();
|
||||
});
|
||||
</script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// listen to any DOM change and automatically perform spacing via MutationObserver()
|
||||
pangu.autoSpacingPage();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script async onload="panguSpaing()" src="https://cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js"></script>
|
||||
@@ -1,21 +1,25 @@
|
||||
<script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22>
|
||||
<text y=%22.9em%22 font-size=%2290%22>👋</text></svg>">
|
||||
<script src="https://cdn-go.cn/aegis/aegis-sdk/latest/aegis.min.js"></script>
|
||||
<script>
|
||||
const aegis = new Aegis({
|
||||
id: 'gQ7V9SgjxZdOm1gy35', // 上报 id
|
||||
// uin: 'xxx', // 用户唯一 ID(可选)
|
||||
reportApiSpeed: true, // 接口测速
|
||||
reportAssetSpeed: true, // 静态资源测速
|
||||
spa: true // spa 应用页面跳转的时候开启 pv 计算
|
||||
});
|
||||
function loadAgies() {
|
||||
console.log('loaded');
|
||||
const aegis = new Aegis({
|
||||
id: 'gQ7V9SgjxZdOm1gy35', // 上报 id
|
||||
// uin: 'xxx', // 用户唯一 ID(可选)
|
||||
reportApiSpeed: true, // 接口测速
|
||||
reportAssetSpeed: true, // 静态资源测速
|
||||
spa: true // spa 应用页面跳转的时候开启 pv 计算
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script async onload="loadAgies()" src="https://cdn-go.cn/aegis/aegis-sdk/latest/aegis.min.js"></script>
|
||||
<link rel="preconnect" href="https://cdnjs.cloudflare.com">
|
||||
<link rel="preconnect" href="https://cdn.jsdelivr.net">
|
||||
<meta http-equiv="x-dns-prefetch-control" content="on">
|
||||
<link rel="dns-prefetch" href="//api.github.com" />
|
||||
<link rel="dns-prefetch" href="//avatars.githubusercontent.com" />
|
||||
|
||||
<style type="text/css">body {font-weight: unset !important;font-family: -apple-system,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Microsoft YaHei,Source Han Sans SC,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif!important;}</style>
|
||||
<style type="text/css">.framed{width: 100%;} .framed .h-anchor{display: none;}</style>
|
||||
<style type="text/css">body {font-weight: unset !important;font-family: -apple-system,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Microsoft YaHei,Source Han Sans SC,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif!important;}
|
||||
.framed{width: 100%;} .framed .h-anchor{display: none;}</style>
|
||||
Reference in New Issue
Block a user