Skip to content

perf: migrate to tinyclip from clipboardy#39538

Open
florian-lefebvre wants to merge 2 commits intogatsbyjs:masterfrom
florian-lefebvre:feat/tinyclip
Open

perf: migrate to tinyclip from clipboardy#39538
florian-lefebvre wants to merge 2 commits intogatsbyjs:masterfrom
florian-lefebvre:feat/tinyclip

Conversation

@florian-lefebvre
Copy link
Copy Markdown

Description

Tinyclip is really lighter than clipboardy. This PR was made as part of the e18e initiative.

Followup to #39487

Documentation

N/A

Tests

N/A

Related Issues

N/A

@gatsbot gatsbot Bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Apr 8, 2026
@florian-lefebvre
Copy link
Copy Markdown
Author

cc @serhalp

Comment on lines -545 to -547
if (`writeSync` in clipboardy) {
clipboardy.writeSync(response.data)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why this one was using the synchronous API and checking for method presence? 🤔

Because it wasn't available in the browser? https://main.npmx.dev/package/clipboardy#user-content-api

Does that apply in tinyclip? The readme says "In the browser, you can use the native Clipboard API instead of a dependency." Does that imply that tinyclip doesn't work in the browser? Does this code need to conditionally use the Clipboard API? 🤔

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why it was using a sync API. Clipboardy sync APIs are not available in the browser anyways: https://github.com/sindresorhus/clipboardy/blob/main/browser.js

So this change doesn't change anything to the current behavior. Now if this code can run in the browser, then yes it would first need checking if we're client side and call the Clipboard API. Let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants