Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Consolidate the code copy button #1374

Merged
merged 2 commits into from
Sep 10, 2017
Merged

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Sep 10, 2017

Adding the code code button was done by manipulating the HTML of
the event body to add a span tag, then adding the onclick handler
after the thing was mounted. Apart from splitting the code between
two places, adding the span tag was, according to Chrome's
profiler, taking up quite a lot of CPU cycles (apparently as soon
as you set the innerHTML on a div). Instead, just build the whole
lot together after the component mounts.

Adding the code code button was done by manipulating the HTML of
the event body to add a span tag, then adding the onclick handler
after the thing was mounted. Apart from splitting the code between
two places, adding the span tag was, according to Chrome's
profiler, taking up quite a lot of CPU cycles (apparently as soon
as you set the innerHTML on a div). Instead, just build the whole
lot together after the component mounts.
Copy link
Member

@ara4n ara4n left a comment

Choose a reason for hiding this comment

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

lgtm, although may be worth factoring out the add button code to a separate function so it can show up in the profiler?

For neatness and also so it can show up separately in the profiler.
@dbkr
Copy link
Member Author

dbkr commented Sep 10, 2017

good point

@dbkr dbkr merged commit cc6123b into develop Sep 10, 2017
Copy link
Member

@ara4n ara4n left a comment

Choose a reason for hiding this comment

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

lgtm, thanks :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants