I've use YSlow to check the load-speed of my web. According to the rule, it is better to have one big external javascript rather than many external javascripts. It is written in the rule that using a lot of external javascript will cause a lot of http request which is not good.
I'm using CKEditor, and I want to combine it with other javascripts into a big external javascript. But, everytime I load it, there is always errors ocured. After read the code, I think I know why is it happens.
if ( CKEDITOR.loader )
CKEDITOR.loader.load( 'core/ckeditor' );
else
{
// Set the script name to be loaded by the loader.
CKEDITOR._autoLoad = 'core/ckeditor';
// Include the loader script.
if ( document.body && (!document.readyState || document.readyState == 'complete') )
{
var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.src = CKEDITOR.getUrl( '_source/core/loader.js' );
document.body.appendChild( script );
}
else
{
document.write(
'<script type="text/javascript" src="' + CKEDITOR.getUrl( '_source/core/loader.js' ) + '"></script>' );
}
}
CK Editor seems to load other external javascript which has location relative to it. Moving the script into other file will surely cause an error.
So, my question is: Is there any general work-around for this? I mean, it might be other scripts with such a behavior (not only CK-Editor).
EDIT: I think using head.js (http://headjs.com/) is the best options here
bodyas they should, end-users won't see any significant change in load speed for 1 vs 3-4 scripts - modern browsers can load scripts in parallel and will only fetch a 304 response from the server.