Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cdnbro

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdnbro

fallback for cdn assets

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Build Status js-standard-style

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 cdn

Solution

  • load assets asynchronously
  • if cdn times out - load fallback
  • mark cdn as failed for 1 day and use fallback sources during that

Example

<html>
<head>
	<script>
	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);
	</script>
</head>
<body>
	<div class="spinner"></div>
</body>
</html>

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

Keywords

FAQs

Package last updated on 31 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc