Skip to content

Build time with syntax highlighting in 0.22.0 is 50x slower than in 0.21.0 #40

Description

@ziggi

Bug Report

Environment

Zola version: 0.22.0
OS: macOS 15.7.3

Expected Behavior

Enabling syntax highlighting should not significantly degrade build performance compared to previous versions.

Current Behavior

Build times:

  • 0.21.0 without syntax highlighting: 120ms
  • 0.21.0 with syntax highlighting: 320ms
  • 0.22.0 without syntax highlighting: 110ms
  • 0.22.0 with syntax highlighting: 6500ms (6.5s)

config.toml for 0.21.0:

[markdown]
highlight_code = true
highlight_theme = "OneHalfLight"
extra_syntaxes_and_themes = ["syntaxes"]
insert_anchor_links = "right"
external_links_no_follow = true

config.toml for 0.22.0:

[markdown.highlighting]
theme = "github-dark"

Build time depends on the number of code blocks. Some languages are faster, others slower: js and ts produce the same results, but coffee is about 4.5x faster. php is also slow. Even though c is about 5x faster than ts, overall the build is still slow - for example, 150 c blocks result in a build time of around 1100 ms.

Step to reproduce

Add this code (or any other) to your markdown file with ts syntax highlighting, copy and paste it as many times as needed, and measure the build time.

const createResultElement = (result: FuseResult<SearchIndexItem>) => {
  const el = document.createElement('a');
  el.classList.add('search-results__item');
  el.href = result.item.url;

  const titleEl = document.createElement('div');
  titleEl.classList.add('search-item__title');
  titleEl.innerHTML = result.item.title;

  const textEl = document.createElement('div');
  textEl.classList.add('search-item__text');
  textEl.innerHTML = result.item.body.slice(0, 100);

  el.insertAdjacentElement('afterbegin', textEl);
  el.insertAdjacentElement('afterbegin', titleEl);

  return el;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions