browserify-cdnjs

0.1.6 • Public • Published

Browserify-cdn

Browserify tranform to use require() loading resources from jsDelivr.

Usage

require('jquery.cdn');
 
// Transforms to:
 
require('.cdncache/jquery/main.js');
  1. Recognizes if the required file name contains a .cdn extension.
  2. Check if the required library is already downloaded.
  3. Transforms the required file name to the relative path of the downloaded library.
  4. If isn't downloaded, checks if the required library exists on jsdelivr.com.
  5. Downloads the latest mainfile of the library into the .cdncache directory via this url: https://cdn.jsdelivr.net/<library>/latest/mainfile
  6. Transforms the required file name to the relative path of the downloaded library.

Install

npm install browserify-cdnjs

Usage in your build script

// gulpfile.js
 
var cdnjs = require('browserify-cdnjs');
 
browserify('index.js')
  .transform(cdnjs)
  .bundle();

Package Sidebar

Install

npm i browserify-cdnjs

Weekly Downloads

2

Version

0.1.6

License

ISC

Last publish

Collaborators

  • dsdenes