views:

39

answers:

2

Hi. i am using jquery and jquery ui plugins in my web application. and i have some asp.net server controls that they register their scripts on the page. Since my application should be work Local could i put all scripts in master page ? all scripts i mean jquery script and jquery Ui scripts such as DatePicker Dialog and effects. or is there any better way exist? because i want to jquery in all my pages and user Controls. thanks.

+1  A: 

Yes, put them all in the Master Page.
Once they're downloaded, they'll be cached in the browser (if they already aren't)

Marko
Correction: once they're downloaded they *may* be cached by the browser, it depends if the server is setting the appropriate cache headers on those files.
Nick Craver
@Nick hahaha! Next time I'll consult with my lawyer before posting :))
Marko
@Marko - I don't mean to be anal about it, it's just all to common that people *assume* this happens and are ignoring a major performance issue (and low-hanging fruit) that affects their users...so easy to fix, but false assumptions that it's *already* done too much of the time. Hopefully at least one programmer thinking that is reading this right now (yes, you!) and a light bulb's going off :)
Nick Craver
@Nick - that's a very valid point and I do hope that someone **does** read your comment! I was kinda refering to the Google CDN hosted jQuery, which of course already has caching enabled on the server :)
Marko
@Nick - now watch your rep go to 100k - I'm gonna be responsible for the 6 votes that lead to the big number :) Congratulations!
Marko
most companies uses some third party company which caches for you , for example akamai. They cache it for you. the intial request comes to your server and then subsequent requests go to akamai.
gov
+2  A: 

Sticking them in the master is definitely the simplest approach if you intend to have them available on every page.

It sounds like you're including all the scripts individually though, you can include just one file for jQuery UI, for instance:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"&gt;&lt;/script&gt;
Nick Craver
77 rep to go Mr Craver :) You excited?
Marko
@Marko - o wow, actually wasn't paying attention for hours until you commented, sweet :)
Nick Craver
@Nick , how are you getting time to answer so many questions and work as well.you are sharing lot of knowledge thanks
gov
@gov - multi-tasking! I like various topics, work today consisted completely of linq/sql server....so javascript's a fun side-project :)
Nick Craver
@Nick: ya..you have very good reputation...:)
klox
Does this Script ==><script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script> Contains Main Jquery Script Or not ?
shaahin
@Shaahin - it does not, use `https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js` for that (in a separate `<script>` block *before* the jQuery UI one), you can find all the libraries google hosts here: http://code.google.com/apis/libraries/devguide.html
Nick Craver