Skill Level: Advanced
The Tealeaf Web Worker script relies on the fetch API for network communication. The Tealeaf¬†Web Worker script does not function on browsers that do not support fetch. Thus, the initialization of the Tealeaf Web Worker in the UIC queue configuration is conditional on the availability of the fetch API.
Modern browsers allow the creation of background tasks within the context of a web application. This technology is referred to as web workers. With UIC 5.6.0 (and above), applications can use the optional Tealeaf¬†Web Worker script to offload the JSON serialization, gzip encoding, and network communication tasks. Some processing that would otherwise occur in the main application thread¬†is moved into a parallel worker thread, which results in a performance boost.¬†
The performance improvement varies depending on the application. In general, applications that have large DOM sizes and make heavy use of the CPU are more likely to experience performance improvements when using the Tealeaf Web Worker script.
Deploy the Tealeaf Web Worker script
To deploy the Tealeaf¬†Web Worker in your application, follow these steps:¬†
Copy the Tealeaf Web Worker script from the UIC release bundle into your working directory.
The Tealeaf Web Worker script (tltWorker.js) is included in the UIC release bundle in the Worker folder.
Open the Tealeaf Web Worker script in a text editor and copy the pako gzip encoder script into the beginning of the file.
Save the Tealeaf Web Worker script to the web server directory that hosts application scripts.
It is recommended that you add the tltWorker.js script to the same folder and path as the UIC, but it is not required.¬†
NOTE:¬†The Tealeaf Web Worker script cannot be combined with the UIC or any other script.
Verify the Tealeaf Web Worker script is accessible in a browser by using the URL.
Initialize the deployed Tealeaf Web Worker script.
To inialize the deployed Tealeaf Web Worker script, add the tltWorker property to the UIC queue configuration and replace /js/tltWorker.js with the actual URL or path of the Tealeaf Web Worker script as tested in step 4.
The Tealeaf Web Worker is deployed in your application.¬†