Odys
Odys

Reputation: 9090

Can I attach more than one functions to Document.Load using jQuery?

I am planning on separating independent .js files and I wonder if I can use them together after that.

The problem might be that all of them have something similar to

$(function() { code here };

Is it safe to make jQuery to run multiple times, from different locations, this method?

Upvotes: 0

Views: 82

Answers (4)

bittersweetryan
bittersweetryan

Reputation: 3443

If you are using many .js files you might want to use require.js (http://requirejs.org/). This framework will optimize the loading of multiple scripts.

Upvotes: 1

Dennis
Dennis

Reputation: 32598

Yes. .ready(callback) is shorthand for .bind("ready", callback);. Event bind calls in jQuery let you add multiple handlers for a single event.

Upvotes: 0

genesis
genesis

Reputation: 50976

YES

I see no reason why wouldn't you be able to "run" jQuery multiple times.. It's function and function is about to be albe to be called multiple times

Upvotes: 0

Timbo
Timbo

Reputation: 4533

Yep, that should be fine. And you can reuse document.ready() too (info from jQuery docs here).

Upvotes: 0

Related Questions