I am learning jQuery and have a created several plug ins.
Unfortunately due to my company’s coding practices they want all javascript code to be extract out to js files. This for me poses two challenges:
- Can i extract the actual $(document).ready(..) call to a js file? So far with my limited knowledge I have not figured if this at all possible. If not, I welcome any suggestions to make this cleaner and more acceptable way to include this code.
- There are too many javascript includes for each asp.net page header since I may be using several plugins. Is there a way to reduce the potential costly server trips that I would need to make each time I need these files?
Any suggestions, corrections are greatly appreciated
thanks
1.Absolutely.Just add a script reference to your html like this:
Then just start your .js file with
or any other shortcut ways of starting the jQuery code block.
2.You should run your scripts through something like Minify before sending them off to the user. This will combine the files and pack them in nicely, so that they take up less space.