As we all know, jQuery is now very popular, and jQuery has already been used on Baidu's new homepage. Today we will summarize how to write better jQuery code to make jQuery Code better and faster to execute, I hope this jQuery tutorial will change your previous unreasonable practices.
1. Correctly reference jQuery
1. Try to introduce jQuery before the body ends, rather than in the head.
2. Use a third-party CDN to introduce jQuery. Note that when a problem occurs with a third-party CDN, you must introduce a local jQuery file. (For websites that have already used cdn, you can ignore this because the user's bandwidth has been upgraded. It is not necessarily stable to put other users on the machine)
3. IfIf the script file is introduced before, you do not need to write document. ready, Because DOM has been loaded when the js code is executed.