Home > Web Front-end > JS Tutorial > body text

javascript dynamic loading 2_javascript skills

WBOY
Release: 2016-05-16 17:50:29
Original
1295 people have browsed it

In the previous article on javascript dynamic loading, it was mentioned that the use of synchronous loading strategy is used to implement such as

Copy code The code is as follows:

Using("jquery");
Using("User");

$("#ID").click(function(){
var user = new User();
user.name = "xx";
user.show();
});

Since JS is single-threaded, so The synchronization strategy brings many disadvantages, such as preventing subsequent code from running and causing the browser to freeze.
It is difficult to achieve the effect of using the leading package later using the asynchronous strategy. It can only be done in the form of callback, which is not what UsingJS wants to achieve. After all, jQuery's getScript function can achieve this method.

After some thinking, I finally came up with a solution on how to solve the problem of booting packets in an asynchronous manner. Let’s first look at the programming method after adopting this solution.
Copy code The code is as follows:

< /div>


Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!