Various Options to user Jaquery in your SharePoint or SharePoint Online site.
Option 1 -You can use the JQuery library hosted on Microsoft’s content delivery network (CDN). The CDN geographically distributes the fi le around the world, making it faster for clients to download the file. With SharePoint on-premise installations, such as your intranet, this is not as important, but with SharePoint Online or SharePoint-based Internet sites, this will increase the perceived performance of your site.
Add the following script tag to your page to use the Microsoft CDN to load the jQuery library.
<!-- <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js" type="text/javascript">
</script> -->
Option 2 - The next approach is to use the ScriptLink control.Add the following ScriptLink server-side tag to your page to load the jQuery library.
<!-- <sharepoint:scriptlink defer="false " id="SPScriptLink " localizable="false " name="jquery-1.4.2.js " runat="server"></sharepoint:scriptlink> -->
Few things about ScriptLink control -
* The ScriptLink control ensures that the script is loaded only once and will also ensure that other dependencies have been loaded first
* The ScriptLink control requires that you put the jQuery library file in the LAYOUTS directory, C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS.
* Cannot be used with sandboxed solutions.
Option 3 -The third method, and the one that you should use, is to load jQuery using the Microsoft Ajax script loader, or another client-side script loader.
You will need to download the Start.js library to your Site Assets library’s Script folder to hold your scripts. You can find the current script loader on Microsoft’s CDN at the following URL. http://ajax .microsoft.com/ajax/beta/0910/Start.js.
You should also download the source version for development from the following URL. http://ajax.microsoft.com/ajax/beta/0910/Start.debug.js. Alternatively, you could load the Start.js library directly from the Microsoft CDN.
There are two steps to loading the jQuery library, or any of your custom JavaScript libraries.
* First, reference the script loader on your page using the following script tag. Or, if you are loading the library from the CDN, use the following script tag instead.
<!--
<script src="http://ajax.microsoft.com/ajax/beta/0911/Start.js " type="text/javascript">
</script>
-->
* The second step is to reference the jQuery library or your own libraries using the Sys.loadScripts method, which is part of the Start.js library. The Sys.loadScripts method takes an array of scripts to load and a callback function to call when they have been loaded. Add the follow code to load the jQuery library.
<!--<script type="text/javascript ">
Sys.loadScripts(["/SiteAssets/Scripts/jquery-1.4.2.js "], function() {
alert("jQuery Loaded ");
});
</script> -->
* The second step is to reference the jQuery library or your own libraries using the Sys.loadScripts method, which is part of the Start.js library. The Sys.loadScripts method takes an array of scripts to load and a callback function to call when they have been loaded. Add the follow code to load the jQuery library. Sys.loadScripts(["/SiteAssets/Scripts/jquery-1.4.2.js "], function() { alert("jQuery Loaded "); });