Collapse code + Infinite Restore (Bug fixed) + Persistent Config + Reduce lag
Improves performance in long Google AI Studio conversations by reducing DOM overload and rendering lag.
Google AI Studio Optimizer is a lightweight userscript that significantly improves performance in long Google AI Studio conversations by reducing DOM overload and optimizing message rendering.
It limits the number of visible messages, detaches older messages into a lightweight JavaScript memory pool, and adds optional code block collapsing.
Everything runs locally in your browser. No network requests, no tracking, and no modification of AI responses.
Make long Google AI Studio sessions faster, smoother, and completely lag-free without changing how the AI works.
Click the big green Install button
or Download: https://raw.githubusercontent.com/Kfayyy/Google-AI-Studio-Optimizer/main/google-ai-studio-optimizer.user.js
If you encounter any problem, please open an issue: https://github.com/Kfayyy/Google-AI-Studio-Optimizer/issues
Large conversations in Google AI Studio can become slow because:
This userscript eliminates lag by:
MIT
After installing the script and opening Google AI Studio, the optimizer starts automatically in the background. No additional setup is required.
The script adds two modern floating buttons at the bottom center of the page:
Click the 🚀 button to open the Optimizer panel. All changes are saved automatically.
Available options:
Controls how many messages remain actively visible in the conversation.
Example:
35 → only the latest 35 messages remain visibleLower values:
Higher values:
Controls how many hidden messages are brought back each time you click Restore.
Example:
10 → clicking Restore will bring back the latest 10 hidden messages.Useful when you want to temporarily scroll up and view an older part of the conversation.
Controls how many hidden messages are kept directly in the DOM (hidden via CSS).
Example:
50 → the latest 50 hidden messages remain in the DOM.Enables or disables the optimization instantly.
ON: The script is active and manages the DOM.
OFF: The script instantly reattaches all messages in their exact chronological order and restores the default Google AI Studio behavior. It acts exactly as if the script was disabled—no messy UI, no missing messages, and no page refresh needed!
Restores hidden messages according to the value defined in Restore count.
The button now features a live counter showing exactly how many messages are safely stored in memory (e.g., ⬆ Restore (42 dispo)).
Example:
If Restore count = 10, clicking it will flawlessly bring back the 10 oldest messages from memory into the UI.
Reapplies the optimization using your current Max visible setting.
Example:
If Max visible = 35, clicking Clean will instantly hide everything except the 35 most recent messages, giving you a fresh and lag-free workspace.
The ▼ button collapses all currently visible code blocks instantly.
This significantly improves performance during heavy coding sessions, as fully expanded code blocks require a massive amount of browser rendering power.