cmbn: Generate combos of JavaScript code served via CDNs

Recommend this page to a friend!
     
  Info   View files Files   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 150 All time: 332 This week: 17Up
Version License JavaScript version Categories
cmbn 1.0.1MIT/X Consortium ...1.0Node.js, Performance
Description 

Author

This packages can generate combos of JavaScript code libraries served via CDNs.

It can work as a Web server using Node.js to serve combinations of JavaScript code files more efficiently as a CDN (Content Delivery Network).

The directory from where static files will be served and the expiry time of static files are configurable parameters.

Picture of Gamaiel Zavala
Name: Gamaiel Zavala <contact>
Classes: 1 package by
Country: United States United States
Age: ???
All time rank: 14416 in United States United States
Week rank: 6 Up2 in United States United States Up

Details

# cmbn Several public CDNs host popular JS libs, most notably [cdnjs.com](http://www.cdnjs.com/). Until now there was no easy way to combo the various libs into a single URL in order to maximize performance. This package fills that gap by generating and serving combo URLs across various CDNs and any other public server. ## Install $ npm i cmbn ## Usage This software is currently demoed at cmbn.us but there are no guarantees to availability. It's recommended to install cmbn on your own host in order to enable comboing with application-specific assets. To maximize performance even further cmbn should be fronted by a CDN like [CloudFlare](http://www.cloudflare.com/). ### Standalone server var cmbn = require('cmbn'); cmbn.server.createServer(); ##### Options In addition to the options available for `middleware` ,`createServer` accepts one or more of the following: * `port` - Port to listen on. Default is 80. * `staticDir` - Directory to serve static assets from. Particularly useful if comboing from localhost. * `staticMaxAge` - Number of seconds to set for `max-age` in the `Cache-Control` header if serving local assets. ### Middleware var connect = require('connect'), express = require('express'), cmbn = require('cmbn'), app = express.createServer(); app.use(connect.compress()); app.use(cmbn.server.middleware()); app.listen(80); ##### Options `middleware` takes an optional argument which is an object containing one or more of the following: * `cacheSize` - The size in bytes to reserve for [lru-cache](https://github.com/isaacs/node-lru-cache) which stores fetched assets. Default is `5000000` (~5MB). * `cacheFunc` - The cache function used to determine the size of each asset, default is to return `asset.length`. ### Node Client var cmbn = require('cmbn'), url = cmbn.client.combine([ 'http://cdnjs.cloudflare.com/ajax/libs/require.js/1.0.8/require.min.js', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'' ]); // http://cmbn.us/~cj;require.js,1.0.8,require.min.js/~gg;jquery,1.7.2,jquery.min.js console.log(url); ##### Options `combine` also takes an optional argument which is an object containing one or more of the following: * `host` - The hostname[:port] which is running cmbn. Defaults to cmbn.us (see note under Usage). * `protocol` - The protocol for the host running cmbn. Defaults to `http`. ### Browser Client <script src="http://cmbn.us/libs/cmbn/0.0.1/cmbn.min.js"></script> <script> var url = cmbn.client.combine([ 'http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', 'http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.min.js' ]); // http://cmbn.us/~gg;swfobject,2.2,swfobject.js;jquery,1.7.2,jquery.min.js/~ms;jquery.ui,1.8.10,jquery-ui.min.js console.log(url); </script> ##### Options See Node Client. ### Adding a CDN var cmbn = require('cmbn'); // add cdn for localhost cmbn.cdns.addCdn('lh', {host: 'localhost:8080', prefix: 'libs/'}); var url = cmbn.client.combine([ 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', 'http://localhost:8080/libs/cmbn/0.0.1/cmbn.min.js' ], {host: 'localhost:8080'}); // http://localhost:8080/~gg;jquery,1.7.2,jquery.min.js/~lh;cmbn,0.0.1,cmbn.min.js console.log(url); ### Run the Example After installing the package run `node examples` from the package root. A link will be output by the client and the server will start. Copy the link and paste it into a browser to see the comboed output. ### More See the examples folder and code for more usage information. ## License MIT License. See the accompanying LICENSE file for terms.

  Files folder image Files (16)  
File Role Description
Files folder imagebuild (2 files)
Files folder imageexamples (3 files, 1 directory)
Files folder imagelib (3 files)
Accessible without login Plain text file index.js Conf. Auxiliary script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file package.json Data Auxiliary data
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files (16)  /  build  
File Role Description
  Accessible without login Plain text file copyright.js Conf. Configuration script
  Accessible without login Plain text file index.js Aux. Auxiliary script

  Files folder image Files (16)  /  examples  
File Role Description
Files folder imagepublic (1 file, 1 directory)
  Accessible without login Plain text file client.js Example Example script
  Accessible without login Plain text file index.js Example Example script
  Accessible without login Plain text file server.js Example Example script

  Files folder image Files (16)  /  examples  /  public  
File Role Description
Files folder imagelibs (2 directories)
  Accessible without login HTML file index.html Doc. Documentation

  Files folder image Files (16)  /  examples  /  public  /  libs  
File Role Description
Files folder imagecmbn (1 directory)
Files folder imagecss (1 file)

  Files folder image Files (16)  /  examples  /  public  /  libs  /  cmbn  
File Role Description
Files folder image0.0.1 (2 files)

  Files folder image Files (16)  /  examples  /  public  /  libs  /  cmbn  /  0.0.1  
File Role Description
  Accessible without login Plain text file cmbn.js Aux. Auxiliary script
  Accessible without login Plain text file cmbn.min.js Aux. Auxiliary script

  Files folder image Files (16)  /  examples  /  public  /  libs  /  css  
File Role Description
  Accessible without login Plain text file paths.css Data Auxiliary data

  Files folder image Files (16)  /  lib  
File Role Description
  Accessible without login Plain text file cdns.js Class Class source
  Accessible without login Plain text file combine.js Class Class source
  Accessible without login Plain text file server.js Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:150
This week:0
All time:332
This week:17Up