Skip to content

FR: Support compression for embedded JSON data in Sigma.write_html() #253

@zlatent

Description

@zlatent

Is your feature request related to a problem? Please describe.

When exporting large graphs using Sigma.write_html(), the resulting HTML file can become significantly large. This is primarily because the graph data (nodes and edges) is embedded as a raw, uncompressed JSON string within the HTML file. For complex networks with many attributes, this file size can make sharing or hosting the visualization difficult.

Describe the solution you'd like

I would like to request a new parameter for Sigma.write_html() (e.g., compression=True or json_compression='gzip') that compresses the underlying graph data before embedding it.

Proposed workflow:

  1. Python side: The graph JSON is generated, GZIP compressed, and potentially Base64 encoded.
  2. HTML Template: The template includes a small decompression library (like pako or using the DecompressionStream API if browser support allows) to inflate the data on the client side before passing it to Sigma.js.

Describe alternatives you've considered

  • Manually zipping the HTML file: This works for transport but requires the recipient to unzip the file before viewing it.
  • Hosting data externally: Loading a separate .json.gz file works but sacrifices the convenience of a single, self-contained HTML file that write_html provides.

Additional context

Adding this feature would significantly reduce the file size of exported visualizations, keeping them portable and easier to share via email or static hosting, especially for graphs with thousands of nodes/edges.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions