using jQuery plugins with browserify: jQuery is not defined
See original GitHub issueI am trying to use browserify with jQuery and a jQuery plugin like so:
var $ = require('jquery');
require('./lib/stellar.jquery')
$(function(){
$.stellar();
});
I build the final file using gulp (not sure if this matters):
gulp.task('browserify', function(){
return browserify({
entries: ['./js/main.js']
})
.bundle()
.on('error', function (err) {
console.log(err.toString());
this.emit('end');
})
//Pass desired output filename to vinyl-source-stream
.pipe(source('bundle.js'))
// Start piping stream to tasks
.pipe(gulp.dest('./build/'));
});
Anyway when I run in the browser this last line from the stellar.jquery.js
file throws a “jQuery is not defined” error:
...
// Expose the plugin class so it can be modified
window.Stellar = Plugin;
}(jQuery, this, document));
What’s the best way to use jQuery plugins with browserify?
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
order dependencies: jQuery is not defined with browserify
I am trying to use a plugin that is ...
Read more >Javascript – order dependencies: jQuery is not defined with browserify
I am trying to use a plugin that is in /js/lib/stellar.jquery.js : var $ = require('jquery'); require('./lib/stellar.jquery') $(function(){ $.stellar(); });.
Read more >5 Easy Ways to Fix the "jQuery is Not Defined" Error - Kinsta
The "jQuery is not defined" error means a call for a specific jQuery that wasn't available when the website loaded. Here's how to...
Read more >Browserify support for JsRender and JsViews
Note: In fact if jQuery is not defined globally, require('jsrender') ... as a plugin (attached to that jQuery instance) – and returns the...
Read more >jquery - npm
For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should just do
global.jQuery = require("jquery")
.This one still works!!