Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add an example

  • Loading branch information...
commit 30561fc7c6bebea5f3c32b545fec75f445db03aa 1 parent b4a069b
@benatkin authored
View
10 README.md
@@ -42,6 +42,16 @@ var jquery = require('br-jquery').jquery();
The *jquery* package on npm is currently a 1.6 release so that may be
one reason to use this package instead.
+## Example
+
+To run the example:
+
+```
+cd example
+npm install
+npm start
+```
+
## Verifying
To verify that this contains the original jQuery source with a simple
View
21 example/hello.js
@@ -0,0 +1,21 @@
+console.log('Hello!');
+window.$ = require('jquery');
+var $ = require('jquery');
+$(function() {
+ $('<div>')
+ .appendTo('body')
+ .css({
+ display: 'none',
+ position: 'absolute',
+ top: '50px',
+ left: '50px',
+ width: '500px',
+ height: '100px',
+ background: '#bfb',
+ fontSize: '36pt',
+ lineHeight: '90px',
+ textAlign: 'center'
+ })
+ .text('Hello, World')
+ .fadeIn(5000);
+})
View
8 example/index.html
@@ -0,0 +1,8 @@
+<html>
+ <head>
+ <title>Hello, Browserify+jQuery!</title>
+ <script src="bundle.js"></script>
+ </head>
+ <body>
+ </body>
+</html>
View
10 example/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "hello",
+ "version": "0.0.1",
+ "dependencies": {
+ "express": "*",
+ "br-jquery": "*",
+ "browserify": "*"
+ },
+ "private": true
+}
View
22 example/server.js
@@ -0,0 +1,22 @@
+var app = require('express').createServer(),
+ fs = require('fs'),
+ browserify = require('browserify');
+
+var html = fs.readFileSync(__dirname + '/index.html', 'utf8'),
+ js = browserify({
+ require: {jquery: 'br-jquery'},
+ entry: 'hello.js'
+ }).bundle();
+
+app.get('/', function(req, res) {
+ res.send(html);
+});
+
+app.get('/bundle.js', function(req, res) {
+ res.header('Content-Type', 'text/javascript');
+ res.send(js);
+});
+
+app.listen(5000, function() {
+ console.log('listening on port 5000...');
+});
Please sign in to comment.
Something went wrong with that request. Please try again.