I have a one page web application, which means alot of javascript. External scrip开发者_如何学JAVAts like facebook connect etc most visitors wont use, so i'd like to know the BEST method of loading js files on an event (click, hover, timer etc). Idealy with jquery.
jQuery has getScript() function.
jQuery.getScript( url, [ success(data, textStatus) ] )
Generate a <script>
element, append it to document.body
Having one, single, minified, gzipped script probably isn't going to be that significant a bandwidth cost though.
精彩评论