Skip to content

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

Notifications You must be signed in to change notification settings

dsdenes/browserify-cdnjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

browserify-cdnjs

Browserify tranform to use require() for 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();

About

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

Resources

Stars

Watchers

Forks

Packages