Setting jquery language on all pages /or from parent page
How would you let the browser only read the jquery language file once? If I have too pages with jquery elements on them say parent and child.
Where parent requies child :
$(document).ready(f开发者_如何学运维unction(){
var id=$('#id').attr('value');
$('#DIV').load('child.php?id='+id);
});
without the src="http://code.jquery.com/jquery-latest.js
on the child page?
Browsers automatically cache static resources such as javascript files. So if you have a reference to jquery on your home page and then reference it all over the other pages the browser won't fetch it from the server for child pages. It will fetch it from the cache. Also if the static resource is in the cache it might not even fetch it for the home page. That's one of the reasons why people use Content Delivery Networks for common files such as jquery. So basically you shouldn't worry too much about this: simply include jquery on all pages that require it and let the client browser handle the caching.
精彩评论