Jquery tutorial (2) faster loading than window. onload

Source: Internet
Author: User

Window. onload () is a tough guy in traditional Java scripts. It has beenProgramAs a shortcut to solve the problem of loading client pages as soon as possible.

But sometimes it is not fast enough to wait for the page to load.

Only a few large image files are quickly loaded, while most large image files make window. onload () Loading very slow. So when I create a web application for my recent online marketing, I have to make it faster. Some new research on window. onload () (such as brother cake)CodeIs a fast method. If you need it, try it.

But if you want to program some Dom (Document Object Model) Java Script, why don't you try jquery? It's like making a cake and tasting it yourself. (Double-off brother cake ).

Jquery has a handy small function used as a Dom to quickly load Java Script, that is, ready... It is executed after the page is loaded.

 
$(Document).Ready(Function(){// Your code here...});

You can use it to load any Java Script you want to load. It does not have to retain the jquery encoding style. It is also possible for jquery to execute multiple functions at the same time.

You may have seen functions like Init () before, and you will find jquery is much faster.

This function will be used over and over again in future tutorials.

OK. Now you can try the Code: (remember to reference jquery to your page. If you don't remember it, see the previous article .)

 
$(Document).Ready(Function(){Alert("Congratluations! ");});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.