Lazy Syntax Highlighter

Description

Lazy Syntax Highlighter highlights code on the server, once, and caches the result. Your visitors download a couple of kilobytes of CSS and no JavaScript at all. There is no flash of unstyled code, nothing to wait for, and nothing to break when a script fails to load.

Free forever core — server-side rendering, caching, around 185 languages, all five themes, and the full Enlighter compatibility layer are in the free plugin. No block cap, no watermark.

Migrating from Enlighter?

Since WordPress 6.3 moved the post editor into an iframe, Enlighter blocks can render unstyled while you’re writing them — and if you have hundreds of posts already using it, rewriting them all isn’t realistic.

Install Lazy Syntax Highlighter and your existing Enlighter blocks render correctly again immediately, automatically — on the front end and in the editor. Nothing is written to your database. Not one post is modified. Deactivate the plugin and your posts are exactly as they were.

That is not a trial feature. It is in the free plugin, permanently.

Safe to remove, too. Uninstalling Lazy Syntax Highlighter converts every block it created back into a standard WordPress Code block, and the compatibility layers never wrote anything to begin with — so you are never locked in, and removing the plugin never leaves your site broken.

What you get

  • A code block that highlights on the server — the HTML arrives already coloured, with no front-end JavaScript
  • Rendered HTML cached in its own database table, warmed automatically when you save a post
  • Five hand-tuned themes, every token colour checked for WCAG AA contrast
  • Line numbers, line highlighting, a starting line number, and a hover effect
  • Multi-line folding — collapse line ranges behind a summary row, with no front-end JavaScript
  • Inline highlighting — a toolbar button that colours a run of code inside a sentence
  • Syntax highlighting while you type, right in the block editor, with a one-click language guess
  • A header bar — none, or the macOS “headlights” dots — plus site-wide font, size, line-height, corner and padding controls
  • An optional copy-to-clipboard button — about 1 KB, deferred, and loaded only on pages that use it
  • Tab-to-space conversion, so indentation looks the same in every browser
  • Around 185 languages, with PHP, JavaScript, Python, PowerShell, Bash, HTML, CSS, SQL, JSON and YAML given the most attention
  • Code in comments, using Enlighter’s shortcode syntax — existing Enlighter comments keep working untouched
  • WordPress’s own Code blocks are picked up too, so every code block on the site looks the same without touching a single post

Fast by construction

  • Nothing is enqueued on pages without a code block. No CSS, no JavaScript, nothing.
  • Highlighting never runs on a cache hit.
  • Only the one grammar a block actually needs is loaded, not all 185.
  • The cache lives in its own table, never in the autoloaded options blob.
  • If you run Redis or Memcached, a cache hit never touches the database at all.
  • Output is identical for every visitor, so full-page caches and CDNs cache it normally.
  • No webfonts. No external requests. Ever.

Why Lazy Syntax Highlighter

Lazy Syntax Highlighter is built and used daily on a real site — not a feature checklist assembled to compete on paper. If you would rather not ship a highlighting engine to every visitor’s browser, or you want your existing Enlighter blocks converted automatically instead of by hand, that is exactly what this is for.

The free plugin is actively maintained and stays that way. There is a paid add-on, Lazy Syntax Highlighter Pro, but it is built on top of the free plugin — every fix and language improvement lands in the free version first.

It is the second plugin in the Lazy family, alongside LazyLink, and shares the same rules: vanilla PHP and core WordPress APIs, no third-party services, and nothing phoning home.

Lazy Syntax Highlighter Pro

Lazy Syntax Highlighter Pro is an optional paid add-on that installs alongside the free plugin. Same render engine, same zero front-end JavaScript — the extra themes are CSS, the long-code toggle is CSS, and the Enlighter migration runs on the command line. It adds:

  • 19 more themes, 24 in total — Nord, Dracula, Tokyo Night, Solarized, Gruvbox, Night Owl and eleven of VS Code’s own
  • Three more header-bar styles — muted headlights, a language label, and a language pill with optional custom text per block
  • Reader-friendly long code — collapse long snippets behind a “show more” button, with a site-wide line threshold and a per-block override, still with no front-end JavaScript
  • A site-wide default language, and a per-post default, so you are not setting the language on every block
  • wp lsh migrate — convert every Enlighter block on the site to a native block permanently, with a dry run and a full rollback
  • Priority email support

Details and pricing: https://syntax.lazyadmin.nl

Pro is entirely optional. Nothing in the free plugin is time-limited, capped or watermarked, and if a Pro licence ever lapses every block simply falls back to the free plugin’s styling — your posts are never touched, and any blocks already migrated stay converted.

Privacy

This plugin makes no external HTTP requests, loads no fonts or scripts from third parties, and collects nothing.

Blocks

This plugin provides 1 block.

  • Highlighted Code A syntax-highlighted code block from LazyHighlight. Highlighting happens on the server and is cached, so visitors download no JavaScript for it.

Installation

  1. Install and activate the plugin.
  2. That is all. Existing Enlighter blocks start rendering correctly straight away.
  3. Optionally visit Lazy Syntax Highlighter in the admin menu to pick a theme — the Themes tab previews all five side by side in the language of your choice.

To add a new block, search the inserter for Highlighted Code, or type /code (or /highlight, or a language name such as /php) on a blank line.

FAQ

How is Lazy Syntax Highlighter different from other syntax highlighters?

Most highlighters ship a JavaScript engine to every visitor and colour the code in the browser, which is why code flashes plain before it is styled. Lazy Syntax Highlighter does the work on your server once, caches the HTML, and sends colour with the page. The front end gets a few kilobytes of CSS and nothing else.

Will this change my existing posts?

Not on its own. Both compatibility layers — Enlighter blocks and WordPress’s own Code blocks — work at render time and write nothing to the database. Deactivating the plugin restores the previous behaviour exactly.

Two settings can change posts, and only when you press Update on the post yourself: Convert in the editor (Enlighter blocks, on by default, because those blocks would otherwise render unstyled while you’re writing) and Convert code blocks in the editor (core Code blocks, off by default, because those work fine as they are).

Do I have to convert my Enlighter blocks?

No. They render correctly as they are, indefinitely. If you want to convert one, place the cursor in it and use the block transform.

What about WordPress’s own Code block?

Those are picked up as well: on the front end they get the same theme, padding, line numbers and copy button as a Lazy Syntax Highlighter block, and nothing is written to your database. Core’s Code block stores no language, though, so they arrive without token colours. To get those, opening a post converts them into Lazy Syntax Highlighter blocks in the editor — the change is only saved when you press Update, and both behaviours can be turned off under Lazy Syntax Highlighter in the admin menu.

What happens to my blocks if I delete the plugin?

Your site is not left broken. Deleting the plugin converts every Lazy Syntax Highlighter block back into a standard WordPress Code block, so you are left with working first-party blocks rather than markup from a plugin you no longer have. Your code comes across byte for byte; the per-block language, theme and line settings do not, because core has nowhere to keep them. Deactivating changes nothing at all.

Will the free version keep being maintained?

Yes. The free plugin is the engine the paid add-on is built on, so every fix and language improvement lands here first. It is not going anywhere.

Is there a paid version?

Yes — Lazy Syntax Highlighter Pro, an optional add-on that installs alongside this plugin and adds 19 more themes (24 total), extra header styles, a “show more” toggle for long code blocks, site-wide and per-post default languages, and a one-command WP-CLI Enlighter migration with rollback. The free plugin is complete and unrestricted without it. See https://syntax.lazyadmin.nl.

Does it work with my caching plugin?

Yes. Every visitor gets identical HTML, so full-page caches (WP Rocket, W3 Total Cache, LiteSpeed, Cloudflare) and CDNs cache pages normally.

What happens if I deactivate the plugin?

Code blocks fall back to a plain <pre><code> containing your code, correctly escaped. Readable, just not coloured.

Does it use JavaScript on the front end?

Only if you enable the copy button, and then only on pages that have one. Highlighting itself is entirely server-side.

Which languages are supported?

Around 185, including PHP, JavaScript, TypeScript, Python, PowerShell, Bash, HTML, CSS, SCSS, SQL, JSON, YAML, TOML, Markdown, diff, Dockerfile, Apache, Nginx, C#, Java, Go, Rust, Ruby and C++.

Can readers post code in comments?

Yes — turn it on under Lazy Syntax Highlighter in the admin menu. Comments use Enlighter’s shortcode syntax, so existing Enlighter comments keep working with nothing to convert.

Where can I get support?

Please use the support forum here on WordPress.org.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“Lazy Syntax Highlighter” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.3.1

  • Fixed: a PHP notice (_load_textdomain_just_in_time) on every admin and front-end request with WP_DEBUG on. The theme and header lists were built with their names already translated, during plugins_loaded — too early for WordPress to have loaded any translations. Names are now translated when they are displayed instead.
  • Changed: everything the plugin stores now uses a four-plus-character lazysyhi_ prefix instead of lsh_, so it cannot collide with another plugin. Your settings, render cache and scheduled cleanup are carried over automatically on update — there is nothing to do. Block CSS class names are unchanged, so existing posts are untouched.
  • Changed: the wp lsh migrate bulk-conversion command now ships in Lazy Syntax Highlighter Pro rather than sitting inactive in the free plugin.
  • Fixed: the block editor bundle could be left out of a release archive, which silently removed the “Highlighted Code” block. It is now checked into the repository and verified during packaging.
  • Removed: the Plugin URI header.

1.3.0

  • New: a Free vs Pro tab in the admin screen — what the paid add-on adds, a full feature comparison, pricing and an FAQ. It adapts once Pro is installed, and shows nothing to sell once Pro is active.
  • New: a Help tab — a linkable WP-CLI reference covering wp lsh cache, plus the exact Enlighter attribute mapping the compatibility layer applies.
  • Docs: the readme now states plainly that uninstalling converts blocks back to standard WordPress Code blocks, and that the free plugin stays maintained.

1.2.0

  • Improved: PowerShell, JavaScript, TypeScript, Python and PHP now distinguish declaration/modifier keywords (class, function, const, public, static, this) from control-flow keywords (if, return, for, throw) with a new colour bucket, matching how real code editors like VS Code colour them. Existing code blocks in these five languages will recolour slightly after this update.
  • Fixed: PowerShell cmdlet parameter switches (-Path, -Recurse) no longer share a colour with $variables, in both the front end and the live editor preview.
  • Fixed: PowerShell cmdlet and function-call names (Get-ChildItem, Sort-Object) are now coloured like a function name instead of sharing a colour with type casts like [string]/[int], in both the front end and the live editor preview.
  • Fixed: PowerShell param stays keyword-coloured, matching real code editors, instead of being grouped with declaration keywords.
  • Fixed: PowerShell brackets and braces ((), {}, []) now get a colour instead of rendering as plain text.
  • Fixed: TypeScript interface, class and module names are now coloured; constructor/private/protected/public are no longer left as plain text.
  • The live editor preview (block editor) now applies the same keyword split and PowerShell corrections as the front end, for JavaScript, TypeScript, Python, PHP and PowerShell — what you see while writing now matches what gets published.

1.1.0

  • New: multi-line code folding (foldLines), rendered as a zero-JavaScript <details> summary.
  • New: an “Inline code (highlighted)” editor format for colouring code inside a sentence.
  • New: live syntax highlighting inside the block editor, plus a “Detect from code” language guess.
  • New: a header bar with None and Headlights presets, per block or site-wide.
  • New: a Style settings tab — every appearance default (theme, header bar, corners, typography, line numbers, copy button and more) with a live preview of a code block beside the controls.

1.0.0

  • Initial release.