Skip to content

Instantly share code, notes, and snippets.

@ericsaboia
ericsaboia / fn.js
Created December 5, 2015 11:01 — forked from jescalan/fn.js
lazy-loading require in node
/**
* Requires a library, but only loads it when it's actually used.
*
* lazy_require('fs');
* fs.readFileSync('example.js');
*
* var wow = lazy_require('fs');
* wow.readFileSync('example.js');
*
* @param {String} lib - name of the lib you want to load