Today, more and more people are using widgets on their websites. More and more people are installing third-party code support to display their websites or blogs such as Flickr photos, Twitter status, and iTunes playlists, these increasing widgets, although only about 1% of them are useful, have improved the overall internet landscape.
However, the emergence of widgets also brings about a problem: Using widgets will reduce the speed of your website. In better cases, your widgets comes from a stable and fast server. Worse, your widgets comes from an unstable server, it will have a great impact on your website.
A foreign blog author believes that there is no silver bullet in this regard, and there is no separate method or technology to solve this problem. This is a problem related to many aspects. Companies can use some methods to mitigate the impact of Multiple widgets. However, when the number of widgets reaches a certain level, the problem will always happen. The following are some considerations for javascript providers:
1. Delayed JavaScript Execution
All JavaScript code is expected to run in the first place, but it does not actually work. This is a very common problem. If the script does not need to be changed when the page is read, the script can be executed after the page is read. In this way, the page content can be displayed first. Unfortunately, this is not to say that some Browsers Do This.
2. Reduce the Running Load
When reading a page, everything slows down, so the less code the faster. In addition, it is associated with the entire page search, which causes slow reading of the entire page. In general, any JavaScript program running for more than five seconds will be faulty.
3. Load Balancing requests generate different URLs
Many modern scripts always return the same URL. With the wide application of widgets, the number of concurrent requests on the same server is huge. A better way is to distribute different URLs. Although different URLs can execute the same domain name, it will be a distribution in the future to distribute the browsing pressure.
4. Use a standard library
The worst possible thing is to start everything from scratch, because JavaScript is particularly prone to errors. As in Java, many standard libraries are set in JavaScript, and the standard may be more effective. The original libraries are written by experienced persons who understand system defects, so it is best to use them directly.
5. Think more.
It is important to know that some JavaScript will run on the end user's website. You must know that we are only part of a large system. Development is now able to reduce the possibility of damaging other Widgt, it can also ensure the quality of user experience.
Related Articles]
- Use Javascript to evaluate the user's password input strength
- Compile JavaScript code using function Programming Technology
- PHP + JavaScript to dynamically display the server running progress bar (cool)