开发者

best way to ajax load-in external javascript files with jquery?

开发者 https://www.devze.com 2022-12-25 16:59 出处:网络
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 j

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号