https://github.com/yujiosaka/browserify-jquery-test
A proof of concept that browserify encapsulates jQuery object
https://github.com/yujiosaka/browserify-jquery-test
Last synced: 6 months ago
JSON representation
A proof of concept that browserify encapsulates jQuery object
- Host: GitHub
- URL: https://github.com/yujiosaka/browserify-jquery-test
- Owner: yujiosaka
- Created: 2015-01-02T17:24:41.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-02T18:05:37.000Z (almost 11 years ago)
- Last Synced: 2023-04-09T11:03:49.501Z (over 2 years ago)
- Language: JavaScript
- Size: 199 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
browserify-jquery-test
======================A proof of concept that browserify encapsulates jQuery object
# Concept
When you require jQuery and set the returned object to your variable,
it should not pollute global window object.# Proof
The following code is written in `src.js`.
```
(function() {
var obj = {};
obj.$ = require('jquery');
console.log("typeof $:", typeof $);
console.log("typeof obj.$:", typeof obj.$);
})();
````src.js` and jQuery are compiled to `dist.js` by grunt and browserify.
Run `./node_modules/.bin/static .` and access to `http://127.0.0.1:8080`,
so you will see the following result in your console:```
typeof $: undefined
typeof global.$: function
```# Conclusion
It does not set `$` or `jQuery` object to global `window` object.