-
-
Notifications
You must be signed in to change notification settings - Fork 67
Refactor: optimize JavaScript performance and robustness #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HemantSudarshan
wants to merge
2
commits into
openclaw:main
Choose a base branch
from
HemantSudarshan:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+352
−8,435
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Replace deprecated navigator.platform with userAgentData - Add comprehensive null checks for all DOM operations (23+ locations) - Cache frequently queried DOM elements to eliminate repeated queries - Remove dead code (installCmds, osCmds objects) - Improve clipboard copy with execCommand fallback and visual error feedback - Fix Easter egg animation with null-safety wrapper - Update font loading comment for clarity Performance improvements: - Eliminated 4 DOM queries per state update cycle - Reduced bundle size by ~13 lines of dead code - Added visual feedback for clipboard failures See OPTIMIZATIONS_SUMMARY.md for detailed before/after comparisons
- Remove package-lock.json and pnpm-lock.yaml - Keep bun.lock as primary lock file (per README) - Update .gitignore to prevent future lock file conflicts This prevents dependency version mismatches when different contributors use different package managers.
|
@HemantSudarshan is attempting to deploy a commit to the Amantus Machina Team on Vercel. A member of the Team first needs to authorize it. |
Comment on lines
+552
to
+556
| textArea.style.opacity = '0'; | ||
| document.body.appendChild(textArea); | ||
| textArea.select(); | ||
| success = document.execCommand('copy'); | ||
| document.body.removeChild(textArea); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
| textArea.style.opacity = '0'; | |
| document.body.appendChild(textArea); | |
| textArea.select(); | |
| success = document.execCommand('copy'); | |
| document.body.removeChild(textArea); | |
| textArea.style.left = '-9999px'; | |
| textArea.style.top = '-9999px'; | |
| textArea.style.opacity = '0'; | |
| // Ensure the element is selectable by making it not display: none or visibility: hidden | |
| textArea.setAttribute('readonly', ''); | |
| document.body.appendChild(textArea); | |
| // Focus must be called before select() for reliable execCommand execution | |
| textArea.focus(); | |
| const selected = textArea.select(); | |
| // execCommand('copy') requires the element to be focused and selected | |
| success = document.execCommand('copy'); | |
| // Only remove after ensuring the operation is complete | |
| document.body.removeChild(textArea); | |
| // If execCommand appeared to succeed but didn't actually copy, mark as failure | |
| if (!success) { | |
| console.warn('execCommand(copy) returned false - fallback copy may have failed'); | |
| } |
Missing focus() call and inadequate DOM positioning in execCommand fallback causes unreliable clipboard copy behavior in older browsers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request: JavaScript Performance and Robustness Improvements
📋 Summary
This PR optimizes the landing page JavaScript for better performance, reliability, and future-proofing.
🎯 Changes
1. Fixed Deprecated API Usage
navigator.platformAPInavigator.userAgentDatawith fallback2. Added Comprehensive Null Safety
updateCommands(),updateVisibility(), event listeners, Easter egg3. Performance Optimization
.pm-cmd,.pm-install,.os-cmd, etc.)4. Removed Dead Code
installCmdsobject (13 lines)osCmdsobject5. Enhanced Clipboard Functionality
execCommandfallback for older browsers6. Lock File Cleanup
package-lock.jsonandpnpm-lock.yamlbun.lockas primary (per README).gitignoreto prevent future conflicts📊 Statistics
🧪 Testing
All changes are backwards compatible and defensive:
📚 Documentation
See
OPTIMIZATIONS_SUMMARY.mdfor detailed before/after code comparisons.🤔 Discussion Points
bun.lockbased on the README. Let me know if you prefer keeping multiple lock files.✅ Checklist
OPTIMIZATIONS_SUMMARY.md)Ready for review! Let me know if you'd like any changes or have questions about the approach. 🙌