Skip to content
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

Move code highlighting from client to server #18

Open
saadq opened this issue Nov 20, 2021 · 0 comments
Open

Move code highlighting from client to server #18

saadq opened this issue Nov 20, 2021 · 0 comments

Comments

@saadq
Copy link
Owner

saadq commented Nov 20, 2021

As you can see in the below images from Chrome's performance tab, there is a small delay between when the page has loaded and when the code gets highlighted.

It would be preferable if the highlighting could be done on the server so that the code will already be highlighted by the time it renders.

At the moment, the highlighting is being done here:

useMount(() => {
import('highlight.js').then((hljs) => {
hljs.default.highlightAll()
})
})

Ideally, it should be moved to somewhere here:

const baseUrl = getReadmeBaseUrl(proposal)
const readmeMarkdown = await getReadmeForProposal(proposal)
const readmeHtml = marked(readmeMarkdown, { baseUrl })

Not highlighted Highlighted
no-highlight highlighted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant