Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/debitoor/cdnbro
fallback for cdn assets
https://github.com/debitoor/cdnbro
Last synced: 12 days ago
JSON representation
fallback for cdn assets
- Host: GitHub
- URL: https://github.com/debitoor/cdnbro
- Owner: debitoor
- Created: 2016-01-25T02:55:27.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-31T03:12:37.000Z (almost 9 years ago)
- Last Synced: 2024-09-14T04:11:52.221Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/debitoor/cdnbro.svg?branch=master)](https://travis-ci.org/debitoor/cdnbro) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)
Why
===
* cdn constantly fails, especially cloudfront
* when cdn fails, each asset blocks an execution for 30 sec
* so user gets 90 sec of white screen if you load 3 assets one by one
* we would like to have smaller time out for cdnSolution
===
* load assets asynchronously
* if cdn times out - load fallback
* mark cdn as failed for 1 day and use fallback sources during thatExample
===```html
window.cdnbro(
[
"//dcamghsjgsjl6.cloudfront.net/css/app-aa76b5fb4e.css",
"//dcamghsjgsjl6.cloudfront.net/libs-07b7cfb48a.js",
"//dcamghsjgsjl6.cloudfront.net/scripts-7c0c10b50f.js"],
[
"/css/app-nocdn-724e4424e4.css",
"/libs-07b7cfb48a.js",
"/scripts-7c0c10b50f.js"], 10000);
```
Tech
===
* assets loaded by xhr to control the order and timeouts
* so scripts should have cors enabled, like cloudfront has
* browser support: ie9+, all recent desktop and mobile