requireware

0.2.0 • Public • Published

requireware

Simple middleware to provide asynchronous require() script loading in the browser.

var express = require('express')
  , requireware = require('requireware');
 
var app = express()
 
app.use('/scripts', requireware(__dirname + '/static/scripts'))
app.use(express.static(__dirname + '/static'));
 
console.log('http://localhost:3000');
app.listen(3000);

In your page:

<html>
<script src="/scripts">
// An inner script is run after content is asynchronously loaded.
 
// Load files which add items to `exports`
var EventEmitter = require('events').EventEmitter; 
 
// Load files which aren't `exports` aware.
require('jquery'); 
 
// Load remote files with a callback.
require.remote('http://example.com/remotescript.js', function () { /* ... */ })
 
</script> 
<body>
  <h1>Content displayed before scripts are loaded.</h1>
</body>
</html>

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.2.01latest

Version History

VersionDownloads (Last 7 Days)Published
0.2.01
0.1.10
0.1.00
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.40
0.0.3-13
0.0.30
0.0.20
0.0.1-30
0.0.1-20
0.0.1-10
0.0.10

Package Sidebar

Install

npm i requireware

Weekly Downloads

4

Version

0.2.0

License

MIT

Last publish

Collaborators

  • tcr