4 ways to asynchronously load js, the review begins.
Option 1: $(document).ready
<!DOCTYPE html> <html> <head> <script src="http://common.cnblogs.com/script/jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { alert("加载完成!"); }); </script> </head> <body> <img src="http://images.cnitblog.com/i/121863/201405/222202573569862.jpg" /> </body> </html>
Comments:
1. Need to quote jquery
2. Compatible with all browsers.
Option 2: