Skip to content

Reduce Prism.js bundle size by removing unused languages - #874

Open
Amrit-raj50 wants to merge 1 commit into
git:masterfrom
Amrit-raj50:optimize-prism
Open

Amrit-raj50 wants to merge 1 commit into
git:masterfrom
Amrit-raj50:optimize-prism

Conversation

@Amrit-raj50

Copy link
Copy Markdown
Contributor

This PR optimizes script/prism.js by stripping out languages and plugins that aren't used across the site, helping reduce the bundle size.

Replaces and supersedes #865 from a clean branch off upstream/master with a single commit, as suggested by @chriscool.

@chriscool

chriscool commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

This PR optimizes script/prism.js by stripping out languages and plugins that aren't used across the site, helping reduce the bundle size.

It would be nice if this was a bit more explicit and told which languages and plugins are stripped out. Also I am not sure it's such a good idea to remove languages. Because, even if that didn't happen yet, we might still one day need to highlight code using one of the stripped out languages.

I think it could be justified if the size savings are big, but neither the description nor the commit message say how much we save by removing languages and how much we save by removing plugins. Maybe removing only plugins would bring most of the size savings?

Also now that #873 is merged, in "CONTRIBUTING.md" we say:

Supported languages for syntax highlighting include: `sh`/`bash`,
  `c`, `diff`, `go`, `ini`, `python`, `ruby`, `yaml`, and others.

so I think this PR should remove the languages that it strips out from the supported languages in that sentence. So yeah (contrary to what I suggested before) it should touch "CONTRIBUTING.md" a bit (if it removes languages), but just to change that sentence.

@sivaraam also please take a look.

@chriscool

Copy link
Copy Markdown
Collaborator

I would suggest first sending a PR that:

  • strips out only plugins that aren't used across the site,
  • says how much we save by removing them.

Then, after that first PR has been dealt with, we will be in a better position to determine whether a follow-up PR (to remove a few languages that we are very unlikely to use) is valuable.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

2 participants