Available Domestic Frontend Libraries and Zdir Self-Hosted Solution

frontend libraryZdirCDN accelerationself-hosted libraryBootCDN alternative
Published·Modified·

Xiaoz has been using frontend libraries provided by BootCDN, but recently discovered the website was loading very slowly. F12 analysis revealed that BootCDN was the culprit; all its addresses are now redirected to Cloudflare, which may spell trouble. This article collects currently available domestic frontend libraries and provides a method for self-hosting frontend libraries using Zdir for your reference.

Sina Frontend Library

The Sina frontend library has been around for a long time and is currently quite stable. It supports CDN and HTTPS, but the selection of frontend resources is relatively limited.

Address: https://lib.sinaapp.com/

css.loli.net

The name of this frontend library is unknown; it is provided by a well-known community expert. If you haven't heard of this library, you might have heard of the sm.ms image hosting service, which is also run by this expert. css.loli.net supports Google Fonts, Gravatar avatars, and more.

Self-Hosted Frontend Library with Zdir

With 360 closing its Google Fonts acceleration service, BootCDN being redirected, and even Baidu's frontend library addresses changing frequently (currently unresponsive), it is uncertain how long these libraries will last. Therefore, self-hosting is the most reliable option.

Zdir is a directory listing program developed by Xiaoz. If you are not familiar with it, you can refer to this article for an introduction. Zdir's original purpose was to build a self-hosted frontend library, so it has been optimized for this specific use case.

1. Install Zdir

Zdir is developed using PHP and only requires an environment that supports PHP.

2. Usage

Zdir processes images and CSS/JS links, automatically converting them into HTML tags.

<!-- For example, if the original link is: -->
https://libs.xiaoz.top/jquery/2.2.4/jquery.min.js
<!-- The copied link becomes: -->
<script src = 'https://libs.xiaoz.top/jquery/2.2.4/jquery.min.js'></script>

3. CDN Acceleration

The goal of self-hosting a frontend library is to consolidate common frontend resources and improve the loading speed of static assets, making CDN integration essential.

  • Upyun: Currently offers good support for HTTPS new features and provides a certain amount of free quota through the Upyun alliance. You can register here: https://www.upyun.com/
  • VeryCloud: As introduced in VeryCloud CDN supports HTTPS, 50GB Free Traffic, VeryCloud offers 50GB of free traffic monthly and supports HTTPS.
  • Tencent Cloud: Offers 10GB of free traffic monthly, supports HTTP/2, and has reasonable pricing.
  • Baidu Cloud Acceleration: Has a free version, but the nodes are not very stable. I have used the first three, but not Baidu. Netizens jokingly call it "Baidu Cloud Deceleration."

Summary

Using Zdir allows for convenient management of frontend resources, offering flexibility and full control over what is enabled or disabled.

Zdir Source Code: https://github.com/helloxz/zdir