script, .
<body>, . , , , .
, , , , . DOM, - , .
, , , ( == , == )
, , , script . , script , . , , - , .
script ( ajax/eval), <script>.
2 <script>:
, , ,
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.5.2/jquery.tablesorter.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.5.2/jquery.tablesorter.widgets.min.js"></script>
script , . , , ...
document.write
dom.
document.write('<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>');
, , script , , , , .
document.createElement
createElement dom, , .
, jQuery <script>, . ready_go , jQuery.
(function() {
if (!window.jQuery) {
var jq = document.createElement('script');
jq.type = 'text/javascript';
jq.async = true;
jq.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(jq, s);
jq.onreadystatechange = jq.onload = ready_go;
} else ready_go();
})();
jQuery.getScript
jQuery, - , getScript URL- script script.
function ready_go() {
$.getScript('http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.5.2/jquery.tablesorter.min.js', function () {
$.getScript('http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.5.2/jquery.tablesorter.widgets.min.js', function () {
});
});
}
?
CDN . , , , , .
CDN ;
- , CDN POP, , URL-, .
- CDN, jQuery google CDN , , , .
, ( )
, @Mario @Xharze, 18 .
CDN, , .
, , .
Having one script will simplify your inbox and because the browser will cache the script, additional downloads will not be needed again, especially useful in the application used for long periods of time and access to many pages.
The only advantage is that separate scripts are stored for users who exit the landing page and why we want to optimize for them, they are not going to stay because of this.
NJoy!