Replace Flarum’s Third-Party Static Resources with a Domestic CDN for Faster Access

5,884 0

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:

Plain Text
vendor/flarum/core/views/install/app.phpvendor/flarum/core/src/Http/WebApp/WebAppView.php

Change:

Plain Text
fonts.googleapis.com

to:

Plain Text
fonts.css.network

If you do not need Google Fonts, you can simply delete the entire line.

Emojione

In the following file:

Plain Text
vendor/flarum/flarum-ext-emoji/js/forum/dist/extension.js

Change:

Plain Text
jsdelivr.net/emojione

to:

Plain Text
bootcss.com/emojione/2.2.7

If 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:

Plain Text
vendor/clarkwinkelmann/flarum-ext-emojionearea/js/forum/dist/extension.js

Change:

Plain Text
https://cdnjs.cloudflare.com/ajax/libs/emojione/

to:

Plain Text
https://cdn.bootcss.com/emojione/

Highlight.js

In the following file:

Plain Text
vendor/s9e/text-formatter/src/Plugins/BBCodes/Configurator/repository.xml

Change the following four occurrences:

Plain Text
//cdnjs.cloudflare.com/ajax/libs/highlight.js

to:

Plain Text
//cdn.bootcss.com/highlight.js

Comments

(0)

No comments yet. Start the conversation.

Leave a comment