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
2010-10-26 02:56:08
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
2010-10-26 03:04:56
@Nick hahaha! Next time I'll consult with my lawyer before posting :))
Marko
2010-10-26 03:10:47
@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
2010-10-26 03:20:26
@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
2010-10-26 03:45:15
@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
2010-10-26 03:46:16
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
2010-10-26 05:22:44
+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"></script>
Nick Craver
2010-10-26 02:56:47
@Marko - o wow, actually wasn't paying attention for hours until you commented, sweet :)
Nick Craver
2010-10-26 03:00:20
@Nick , how are you getting time to answer so many questions and work as well.you are sharing lot of knowledge thanks
gov
2010-10-26 03:02:23
@gov - multi-tasking! I like various topics, work today consisted completely of linq/sql server....so javascript's a fun side-project :)
Nick Craver
2010-10-26 03:04:07
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
2010-10-26 03:13:55
@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
2010-10-26 03:17:18