JavaScript Tutorials
JavaScriptOptimizing Event Handlers
Event handlers in Ajax and JavaScript have always been thought is a necessary but simple function to configure. When configured in a traditional manner, Ajax based applications will work as expected – events will be properly loaded and the elements will be handled in an efficient manner. Usually developers would use event handlers to store data in elements in order for the application to run smoothly.
But storing data in elements has a downside. Because elements are continuously stored with data, the Ajax application will eventually run into data storage problem. In the end, you’ll end up with a cache problem that is common in IE browsers.
Every time a data is processed, they will be stored as temporary files. Through continuous streaming of data, information will eventually be clogged up in the local computer. The user may have the data needed but connection with the server will significantly slow down.
That is why it is important to make some changes in event handlers to ensure that data cache will be controlled and will not slow down the operation of the application.
Using Hash Table
Hash tables has been growing in popularity nowadays especially for developers of Java based frameworks and ASP.Net. Hash tables could effectively store data without clogging the system. Instead of using elements for storing data, hash tables could be used in collecting data.
The efficiency of hash tables in storing data is based on its data collection and retrieval. Data collection is almost the same with elements, except that data are tagged with values from hash tables. Data is still stored as temporary files in the system.
The problem is usually on the retrieval since there is just too much data to be searched. Hash table answered that problem by tagging the data and using the same tag for data retrieval. Think of hash tables as index cards for the library. Instead of looking for books in the directly in the library, index cards could be used to quickly scan the available books.
Data Deletion After Unload
Once hash tables have been properly placed in an Ajax or JavaScript based application, the next challenge is to ensure that the data will be removed as soon as the webpage removed. This problem is not on Mozilla but in IEs. As we all know, IE has a bad habit of collecting information and storing them without plans of deletion.
Hash tables will just store the information but will never delete them when the user leaves the website. Developers have to remove the data with the website. Although it could be manually done by users, it would be nice if the developer is responsible enough to ensure that their website is user friendly even if users will opt to leave the website.
Hash tables is a very smart way of controlling data loaded through event handlers. It would easily the operations of elements exponentially. As a result, a good looking website is assured with performance that would be better than expected.
Sponsored Links
