Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

node-style require() for the browser without a build step

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 bin
Octocat-spinner-32 example
Octocat-spinner-32 src
Octocat-spinner-32 README.markdown
Octocat-spinner-32 package.json
Octocat-spinner-32 wreq.js
Octocat-spinner-32 wreq.min.js
README.markdown

wreq

node-style require()s in the browser without a compile step

This module parses the dependency graph of modules at runtime and pre-fetches dependencies using asynchronous XMLHttp in parallel.

example usage

First write some node-style require()s:

js/beep.js:

module.exports = 'beepity'

js/boop.js:

module.exports = 'boop!!!'

js/entry.js:

var beep = require('./beep.js');
var boop = require('./boop.js');

var elem = document.getElementById('res');
elem.innerHTML = beep + ' ' + boop;

Now load up "/wreq.js" and "/js/entry.js" in some script tags. The files that you want to load with wreq should be type="text/wreq". You can get wreq.js from this repository in the root directory.

<script src="/wreq.js"></script>
<script src="/js/entry.js" type="text/wreq"></script>

<div id="res">[]</div>

Now load index.html. That's it, no compile step and you get node-style so-called "synchronous" require()s.

Now let's all stop making those ridiculous arguments that node-style require()s necessarily entail synchronous XHR or a server-side build step or other silliness.

install

Copy wreq.js or wreq.min.js into your project. All done.

license

MIT/X11

Something went wrong with that request. Please try again.