Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details β†’
Socket
Book a DemoInstallSign in
Socket

@speed-highlight/core

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@speed-highlight/core

🌈 Light, fast, and easy to use, dependencies free javascript syntax highlighter, with automatic language detection

Source
npmnpm
Version
1.2.8
Version published
Weekly downloads
4.2M
9.97%
Maintainers
1
Weekly downloads
Β 
Created
Source

Speed Highlight JS

Demo | Wiki | Docs

Screenshot

  • πŸͺΆ Lightweight (~2kB for the core + ~1kB by language)
  • ⚑ Fast (faster than prism and highlight.js on average)
  • 🧹 Minimal Codebase

Simple setup πŸš€

Web

Style/theme (in the header of your html file):

<link rel="stylesheet" href="/path/dist/themes/default.css">

In the body of your html file:

<div class='shj-lang-[code-language]'>[code]</div>
or
<code class='shj-lang-[code-language]'>[inline code]</code>

Highlight the code (in your javascript):

import { highlightAll } from '/path/dist/index.js';
highlightAll();

Auto language detection

import { highlightElement } from '../dist/index.js';
import { detectLanguage } from '../dist/detect.js';

elm.textContent = code;
highlightElement(elm, detectLanguage(code));

Load custom language

import { loadLanguage } from '../dist/index.js';

loadLanguage('language-name', customLanguage);

CDN

<link rel="stylesheet" href="https://unpkg.com/@speed-highlight/core/dist/themes/default.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/speed-highlight/core/dist/themes/default.css">
import ... from 'https://unpkg.com/@speed-highlight/core/dist/index.js';
import ... from 'https://cdn.jsdelivr.net/gh/speed-highlight/core/dist/index.js';

Deno

Use the deno module

import { setTheme, printHighlight } from 'https://deno.land/x/speed_highlight_js/dist/terminal.js';

await setTheme('[theme-name]');
printHighlight('console.log("hello")', 'js');

Node

Use the npm package

npm i @speed-highlight/core
const { setTheme, printHighlight } = require('@speed-highlight/core/terminal');

setTheme('[theme-name]');
printHighlight('console.log("hello")', 'js');

Migrating from prism

Speed-highlight JS is a lighter and faster version of prism that share a similar API

Style

Remove the prism stylesheet in the head of your html file Clone this repository or use a cdn to load our stylesheet

<head>
-  <link href="themes/prism.css" rel="stylesheet" />
+  <link rel="stylesheet" href="https://unpkg.com/@speed-highlight/core/dist/themes/default.css">
</head>

Script

For the script part remove the prism.js script and replace it by a import and a call to highlightAll

<body>
-  <script src="prism.js"></script>
+<script>
+  import { highlightAll } from 'https://unpkg.com/@speed-highlight/core/dist/index.js';
+  highlightAll();
+</script>
</body>

If you want to highlight only a specific element you can use the highlightElement function instead

Code block

For the code blocks replace the <pre><code> by only one <div> And use shj-lang- prefix instead of language- for the class property

-<pre><code class="language-css">p { color: red }</code></pre>
+<div class="shj-lang-css">p { color: red }</div>

And for inline code block you just have to change the class property

-<code class="language-css">p { color: red }</code>
+<code class="shj-lang-css">p { color: red }</code>

Languages supported 🌐

NameClass nameSupportLanguage detection
asmshj-lang-asmβœ…
bashshj-lang-bashβœ…
brainfuckshj-lang-bfincrement, operator, print, comment❌
cshj-lang-cβœ…
cssshj-lang-csscomment, str, selector, units, function, ...βœ…
csvshj-lang-csvpunctuation, ...❌
diffshj-lang-diffβœ…
dockershj-lang-dockerβœ…
gitshj-lang-gitcomment, insert, deleted, string, ...❌
goshj-lang-goβœ…
htmlshj-lang-htmlβœ…
httpshj-lang-httpkeywork, string, punctuation, variable, versionβœ…
inishj-lang-ini❌
javashj-lang-javaβœ…
javasciptshj-lang-jsbasic syntax, regex, jsdoc, json, template literalsβœ…
jsdocshj-lang-jsdoc❌
jsonshj-lang-jsonstring, number, bool, ...❌
leanpub-mdshj-lang-leanpub-md❌
logshj-lang-lognumber, string, comment, errors❌
luashj-lang-luaβœ…
makefileshj-lang-makeβœ…
markdownshj-lang-mdβœ…
perlshj-lang-plβœ…
plainshj-lang-plain❌
pythonshj-lang-pyβœ…
regexshj-lang-regexcount, set, ...❌
rustshj-lang-rsβœ…
sqlshj-lang-sqlnumber, string, function, ...βœ…
todoshj-lang-todo❌
tomlshj-lang-tomlcomment, table, string, bool, variable❌
typescriptshj-lang-tsjs syntax, ts keyword, typesβœ…
urishj-lang-uriβœ…
xmlshj-lang-xmlβœ…
yamlshj-lang-yamlcomment, numbers, variable, string, bool❌

Themes 🌈

A modern theme by default

NameTerminalWeb
defaultβœ…βœ…
github-darkβŒβœ…
github-lightβŒβœ…
github-dimβŒβœ…
atom-darkβœ…βœ…
visual-studio-darkβŒβœ…

Keywords

javascript

FAQs

Package last updated on 24 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts