Replace Flarum’s Third-Party Static Resources with a Domestic CDN for Faster Access
There hasn’t been much worth writing about on the blog lately, so I’ve just been padding it with filler posts. Since I’m used to it, I might as well write another one. As everyone knows, Flarum is a foreign program, so it uses Google’s static resource libraries when loading resources. Due to the Great Firewall in China, loading is extremely slow. Fortunately, there are also many open-source static resource libraries in China, so we can use them to replace googleapis.com. This article uses BootCDN as the example.
Google Fonts
In the following files:
vendor/flarum/core/views/install/app.phpvendor/flarum/core/src/Http/WebApp/WebAppView.phpChange:
fonts.googleapis.comto:
fonts.css.networkIf you do not need Google Fonts, you can simply delete the entire line.
Emojione
In the following file:
vendor/flarum/flarum-ext-emoji/js/forum/dist/extension.jsChange:
jsdelivr.net/emojioneto:
bootcss.com/emojione/2.2.7If you use the Emojione emoji preview extension, since it uses Cloudflare’s CDN and is basically only friendly to mobile users (Hong Kong nodes), you also need to modify the following file:
vendor/clarkwinkelmann/flarum-ext-emojionearea/js/forum/dist/extension.jsChange:
https://cdnjs.cloudflare.com/ajax/libs/emojione/to:
https://cdn.bootcss.com/emojione/Highlight.js
In the following file:
vendor/s9e/text-formatter/src/Plugins/BBCodes/Configurator/repository.xmlChange the following four occurrences:
//cdnjs.cloudflare.com/ajax/libs/highlight.jsto:
//cdn.bootcss.com/highlight.js
Comments
(0)No comments yet. Start the conversation.