I have a one page web application, which means alot of javascript. External scripts 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具有getScript()函数。
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.