因为一些原因国内访问github比较慢,而我的博客又是搭建在GitHub上。
所以为了优化网站,需要一些魔法手段(大雾
使用jsDelivr加速静态资源
jsDelivr是一家免费的全球加速cdn,而且体验相当不错,可以加速css,js,图片等资源。而且使用也很简单,官网给出了教程
// load any GitHub release, commit, or branch
// note: we recommend using npm for projects that support it
https://cdn.jsdelivr.net/gh/user/repo@version/file
// load jQuery v3.2.1
https://cdn.jsdelivr.net/gh/jquery/jquery@3.2.1/dist/jquery.min.js
// use a version range instead of a specific version
https://cdn.jsdelivr.net/gh/jquery/jquery@3.2/dist/jquery.min.js
https://cdn.jsdelivr.net/gh/jquery/jquery@3/dist/jquery.min.js
// omit the version completely to get the latest one
// you should NOT use this in production
https://cdn.jsdelivr.net/gh/jquery/jquery/dist/jquery.min.js
// add ".min" to any JS/CSS file to get a minified version
// if one doesn't exist, we'll generate it for you
https://cdn.jsdelivr.net/gh/jquery/jquery@3.2.1/src/core.min.js
// add / at the end to get a directory listing
https://cdn.jsdelivr.net/gh/jquery/jquery/
简单来说就是把原本的链接改成https://cdn.jsdelivr.net/gh/你的用户名/你的仓库@版本/资源路径
一般来说我的仓库都是
https://cdn.jsdelivr.net/gh/muryor/muryor.github.io@latest/
的形式