This article is also available in 简体中文.




















Choosing the right CDN providers can significantly reduce the page loading time of your viewers. Icarus lets you pick among several built-in CDN provider options for serving third-party libraries and asset files used by Icarus.
This article is also available in 简体中文.
The following CDN functionalities are provided by ppoffice/hexo-component-inferno. Please refer to it for a complete list of supported providers and their configuration details.
Currently, Icarus offers the following built-in CDN providers:
cdnjs)jsdelivr)unpkg)loli)google)loli)fontim)ustc)fontawesome)loli)The default CDN settings are:
1 | providers: |
Additionally, you can also custom CDN providers via URL templates. The template formats for each type of CDN provider are listed below:
1 | https://some.cdn.domain.name/${package}/${version}/${filename} |
You need to replace the actual package name, version of the package, and relative file path with ${package},
${version}, and ${filename} placeholders.
For example, a JavaScript library with the following URL:
1 | https://unpkg.com/d3@5.7.0/dist/d3.min.js |
can be generalized to this:
1 | https://unpkg.com/${package}@${version}/${filename} |
Some CDN providers may adopt different URL schemes.
For example, the moment.js library has the URL like this on CDN.js:
1 | https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.js |
while has the following URL on UNPKG:
1 | https://unpkg.com/moment@2.22.2/min/moment.min.js |
Therefore, you should be aware of the URL format of your custom CDN provider.
By default, Icarus will try to pass in the parameter using npm package name and relative file path
(e.g., moment@2.22.2/min/moment.min.js).
This npm scheme is used by jsDelivr and UNPKG.
Otherwise, if you are using a CDN.js like provider, please prepend [cdnjs] to its URL template:
1 | [cdnjs]https://some.cdn.domain.name/${package}/${version}/${filename} |
You can pass in the URL of a Google Font mirror or compatible webfont CDN.
Icarus depends on the Ubuntu, Oxanium, and Source Code Pro fonts, so make sure your CDN provides those.
The URL template should have two placeholders for font type (icon or font) and fontname:
1 | https://some.google.font.mirror/${type}?family=${fontname} |
You can pass in the URL to a custom FontAwesome CDN. No placeholders are required. The provided custom CDN should at lease have FontAwesome 5 icons as some of them are used in this theme.
1 | https://custom.fontawesome.mirror/some.stylesheet.css |
All of the above should be put in the providers section of the theme configurations:
1 | providers: |
Three helper functions have been defined to help developers include third-party libraries easily with custom CDN support. You can check them out at ppoffice/hexo-component-inferno.
Something wrong with this article? Click here to submit your revision.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。