uiwjs / uiwjs/react-codemirror

Improving `Largest Contentful Paint` time?

Open
#673 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
161
PR merge metrics
No merged PRs in 30d

Description

Hi there, I'm using this library for https://www.timecomplexity.ai, and it's working nicely, so thank you for that!

One issue I'm seeing though is that the Largest Contentful Paint time is quite high because of this library:

Screenshot 2024-07-14 at 3 22 05 PM

Curious if you have any suggestions on how to improve this? I'm using it in a next.js site hosted on Vercel like this:

import CodeMirror from '@uiw/react-codemirror'
import {go} from '@codemirror/legacy-modes/mode/go'
import {xcodeDarkInit} from '@uiw/codemirror-theme-xcode'

export default function Analysis() {
  return (
      <CodeMirror
            value={inputCode}
            placeholder={'Use AI to analyze your code\'s runtime complexity.\nWorks across languages and without requiring headers, imports, or a main statement - just the code itself.\nPlease note that results may be incorrect in subtle (or not so subtle) ways, so use at your own risk!'}
            autoFocus
            editable={!loading}
            minHeight="300px"
            extensions={[
              StreamLanguage.define(go),
              EditorView.lineWrapping
            ]}
            theme={xcodeDarkInit({
              settings: {
                fontFamily: inputCode.length === 0 ? 'var(--font-inter)' : ''
              }
            })}
            onChange={(value: any) => {
              if (value.length > MAX_CODE_LENGTH) {
                setErrorMessage(`Please enter code less than ${MAX_CODE_LENGTH} characters. You are currently at ${value.length} characters.`)
              } else if (typeof errorMessage !== 'string' || typeof errorMessage === 'string' && errorMessage.length !== 0) {
                setErrorMessage('')
              }
              setInputCode(value)
            }}
          />
    )
 }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CodeMirror usage shown in the issue and profile its impact on Largest Contentful Paint in the reported Next.js and Vercel setup. Compare the editor's loading and rendering behavior with the page's LCP measurement; done means identifying a reproducible cause and a clearly validated improvement.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, react, typescript
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.