-
Notifications
You must be signed in to change notification settings - Fork 146
Description
File: content.js
Cause: The extension sends an API request for every paragraph/span/text node, sequentially, even for large pages.
Consequences:
API throttling or blocking by Groq.
Laggy performance and potential browser freezing on large webpages.
Unpredictable user experience, especially on infinite scroll pages
Fix Recommendation: Implement Request Batching & Throttling
Here are 3 ways you can fix/improve it:
Option 1: Limit Elements Per Run
Limit translation to a certain number of elements per session:
const MAX_ELEMENTS = 50;
Option 2: Add Delay Between Calls
Throttle with setTimeout or a sleep() function:
await new Promise(resolve => setTimeout(resolve, 200));
Option 3: Use Promise.allSettled in Batches
Divide nodes into chunks and process them using Promise.allSettled.