I\'m struggling with using Browserify and document ready events. How do I craft a module that exports content only available after the document ready event has fired? How do I
.
In the file going to be browserify the-file.js -o main.js
.
// the-file.js:
var $ = require("jquery");
//......
window.$ = $; // window is the global object in browsers
$(document).ready(function(){
// all the old things here ....
});
Another way might be better:
// the-file.js:
var $ = require("jquery");
//......
(function($){
$(document).ready(function(){
// all the old things here ....
});
})($); // Anonymous function get called with $.