Skip to content

prince-axios/Web-Workers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web Workers Assignment

This assignment explores the use of Web Workers to improve performance and user experience in web applications. Web Workers are a valuable tool for offloading heavy tasks to background threads, thus preventing UI blocking and enhancing responsiveness.

How to Run Locally:

  1. Clone the repository from GitHub.
  2. Open the project directory on your local machine.
  3. Find the index.html file in the project directory.
  4. Open index.html using any web browser of your choice (Chrome, Firefox, Safari, etc.).
  5. The application should now load and be accessible in your browser locally.

Summary of Findings:

Web Workers are essential for offloading CPU-intensive tasks from the main thread, thereby improving performance and user experience. In the research, I found several scenarios where Web Workers can significantly impact performance:

  • Image processing: Web Workers can be utilized to perform image manipulation tasks such as resizing, cropping, and applying filters without blocking the UI thread.
  • Data fetching: Background tasks like fetching data from APIs or performing complex computations on large datasets can be executed in Web Workers, preventing UI freezes.
  • Heavy computational tasks: Tasks like cryptographic operations, complex mathematical calculations, and simulations can be delegated to Web Workers to maintain a smooth user experience.

Challenges Faced:

During the development process, I encountered several challenges:

  1. Communication with Web Workers: Synchronizing data between the main thread and Web Workers required careful handling to avoid race conditions and data inconsistencies. I overcame this challenge by utilizing message passing and structured data formats like JSON.
  2. Debugging: Debugging code running in Web Workers posed challenges due to limited visibility into their execution context. I addressed this issue by logging messages and using browser developer tools to inspect worker threads.

References and Resources:

Submitted By:

Muhammad Affan Maqsood (2021-CS-130)

Submitted To:

Sir Aatif Hussain