Since I swapped from prototype to jquery i'm going through a lot of performance issues I never knew existed before.
but that's not the question. The question is about this function i'm using: (note we have a huuge web application) I'm using this function:
<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div title="jquery ui exists" style="width: 500px; height: 500px; background-color: lightblue" >hover me</div>
<script>
var MyApp ={
loadJsNow: function(libFilename){
//the synchronous call ensures the library is in fact loaded before this
//(which does not work for crossdomain requests, just for docu)
//function returns:
$.ajax({
url: libFilename,
dataType: "script",
type: "GET",
async: false,
cache: true,
complete: function(data){
$("div").tooltip();
}
});
}
}
MyApp.loadJsNow("http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js");
</script>
</body>
</html>
So this function is used to load js files if they are required for a certain element of the web page. Since we have so many pages with sometimes little on them, and sometimes loads on them, this approach seemed to make sense. BUT: Since this functions loads on demand, and not like standardly in the header, i'm not sure whether this creates a performance problem by itself. In FF 10 i get 200-600 ms see here
Have a look here at the different approach with the hardcoded values in header:
Hardcoded head js links i'm getting ~100-300 ms
drop all support for the on demand loading? do you get similar results?
EDIT i want to crossreference this question, because it seems relevant since jquery / firefox seems to not deal the caching of the on demand javascript loading correctly. Sometimes it works, then on the same page it does not work again.
` rather than in your head. The CDN thing is massive though, not sure how many people realise that the freshest version link isn't cached.
– Rich Bradshaw Nov 08 '12 at 14:34