Skip to content

Layout flash/jump when opening markdown files — run_at default causes visible raw text #117

Description

@sporteka2

Hi @Cimbali, thank you for this great extension!

I have noticed a layout "jump" (flash of unstyled content) when opening markdown files. The raw markdown text is briefly visible before the extension replaces it with the rendered HTML.

Root cause

The content_scripts in manifest.json does not specify run_at, so it defaults to document_idle. This means:

  1. Firefox loads and displays the raw markdown text
  2. The content script runs after the page is idle
  3. The rendered article replaces the raw text → visible layout shift

Proposed fix

Add "run_at": "document_start" to the content_scripts entry in manifest.json, so the script runs before the browser paints the raw text.

Alternatively, inject early CSS via a separate content script at document_start to hide <pre> content until the extension renders it:

/* Hide raw markdown until extension renders it */
pre { visibility: hidden !important; }
article { visibility: visible !important; }
@keyframes reveal { to { visibility: visible; } }
pre { animation: reveal 2s forwards; }

Environment

  • Markdown Viewer Webext 1.0.1
  • Firefox 152.0
  • OS: Linux Mint 22.3 (1920x1080)

This is the same issue reported for MD Reader: md-reader/md-reader#156

Would you consider implementing one of these options?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions