Code Monkey home page Code Monkey logo

jsdelivr-auto-fallback's Introduction

jsdelivr-auto-fallback

修复 cdn.jsdelivr.net 无法访问的问题

由于一些原因,cdn.jsdelivr.net 在一些地区无法访问。在网站里添加上 jsdelivr-auto-fallback 代码,可以自动检测 cdn.jsdelivr.net 是否可用, 如果不可用时,会自动把所有 js, css, image 的地址切换到其他可用的域名。

比如

  • gcore.jsdelivr.net
  • fastly.jsdelivr.net

添加方法

  1. 直接复制 index.jsindex.min.js 里的内容,加到网站里。强烈建议添加到 head 标签最上面。
  2. 所有 script 标签加上 defer 属性。如果原来有 async 属性,可以跳过。这个可以避免 pending 状态带来的等待时间,大大提升性能。

Release Note

v0.0.2 (2022/5/20)

  • 为了提升性能,检测方式由 img 标签改成 link 标签 (css)
  • 建议 script 标签都加上 defer 属性,可以大大提升性能
  • timeout 时间由 3 秒改成 2 秒

问题反馈

https://github.com/PipecraftNet/jsdelivr-auto-fallback/issues

License

Copyright (c) 2022 Pipecraft. Licensed under the MIT license.

>_

Pipecraft PZWD BestXTools

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.