jquery-browserify-integration

1.0.1 • Public • Published

jquery-browserify-integration

In your app you are:

  • trying to use jQuery.
  • trying to use browserify.
  • trying to use jQuery plugins.

All at the same time?!?! IS IT EVEN POSSIBLE?

Well sure.

how do i do it?

See the main.js file. If you want to fiddle with how this all works (perhaps try adding your plugins, widgets, and gidgets!), clone the repo and run npm run demo. This will boot a beefy server in order to browserify the demo code and let you load it in the browser directly. Rad!

gotchas!

If you use a jQuery plugin that is designed to work with npm, and you find that require('jquery') statements are returning different instances of jQuery, you need to understand how browserify bundles your code. To use the same jQuery singleton across your module and your dependent modules:

  • use package.json versioning in your dependencies for jquery. Your root jQuery package must be compatible with all of your plugins' package.json jQuery requirements.
  • browserify doesn't concern itself with versions, but npm does. That is, use npm dedupe as needed. npm dedupe will remove each of your modules' jquery if the module can instead use your root project's jquery. In this regard, you don't bundle multiple different versions of jQuery!
    • not sure what jquery instances your modules are using? browserify --deps yourFile.js > depsCheck. You can parse depsCheck, find your module, look at its deps object, and observe the exact jQuery file it will be using!

don't forget

contributing

send dem PRs on over.

Package Sidebar

Install

npm i jquery-browserify-integration

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • cdaringe