AJAX-Tips Tutorials
AJAX-TipsOnLoad for Initial Rendering
OnLoad is one of the most powerful functions in an Ajax based application. With this function developers could easily render other functions which enables asynchronous streaming of data. OnLoad also have the ability to target specific areas in the webpage so that each window will be working independently which further enhances the interactivity of an Ajax based website. What makes OnLoad even more powerful is the ability of the function to interact not only with the server but also with the user as well. Developers could point different functions if OnLoad is optimized in the website.
OnLoad however, requires a lot of preparation for this to be effective. Usually, OnLoad could be found at the middle of the Ajax based application since they come in as a function that will actually interact with the user.
But the requirement of preparation for OnLoad is often disregarded by different developers since OnLoad is also found at the beginning of the webpage. OnLoad is used during initial rendering so that functions will be available for the user as soon as possible. If they are successful with this feat, their applications could be available for interaction to the user at an early stage.
Unfortunately, the availability of the function in an early stage is not realized even when OnLoad is rendered at the early stage. The requirement of preparation is again missed out by developers. Even though they pressure the server for speedier transaction other functions essential for a successful rendering of OnLoad is still not there.
That is why it is recommended to forget about OnLoad during the initial rendering. Instead of spending some of the resources to complete the rendering of OnLoad, developers can just focus other functions to complete the initial rendering of the Ajax application.
Instead of OnLoad, developers can write other functions and place them before the </body> tag. Initial rendering will never have OnLoad but additional functions that speed up the initial rendering of the Ajax application will replace the OnLoad function. You can add images and certain files that will interact with the user once the initial rendering is complete. That’s where OnLoad could come in and start interacting with the application.
Some would think that DOM requires OnLoad to successfully render that function. This is not true since DOM doesn’t need the power of OnLoad but only the support of the server for the function to be completed. DOM is not an interacting function with the user but it is a function that becomes a backdrop for other functions as well.
The basic trick to overcome OnLoad requirement for DOM is quite simple. Instead of providing OnLoad, after the onDOMReady command, developers could just point the onDOMReady to another function. From simple event handlers to image loaders could be used instead of OnLoad. By tweaking onDOMReady and pointing them to simpler functions, the initial rendering will be greatly optimized. Initial rendering doesn’t have to be loaded with heavy functions such as OnLoad, instead simpler functions that is useful as soon as the application is loaded.
Sponsored Links
