Skip to content

v0.10.0 - HTML streaming and performance boost

Choose a tag to compare

@volfpeter volfpeter released this 17 Dec 21:14
ce6e0bb

What's Changed

The main feature is that the library now has a StreamingRenderer that lets you optimize TTFB (time to first byte), basically producing instant responses.

Tags (and the entire html module) have been rewritten to improve performance. Tag creation is now ~35% faster.

Rewritten how ErrorBoundary works, which simplified renderers and improved performance by about ~5-10.

Streaming support will soon land in FastHX and holm as well, to give you the best possible web development experience.

Features

  • Introduce the streaming renderer concept. The default streaming renderer can be imported as from htmy import StreamingRenderer. (by @volfpeter in #94)
  • The baseline renderer can now stream the result, reducing time to first byte to around 0.00001s (several orders of magnitude improvement for a typical webpage). As a side-effect, this renderer's performance is now only about 20-25% worse then the default renderer's. (by @volfpeter in #94)
  • The renderer instance can now be loaded from the rendering context using the RendererContext utility. (by @volfpeter in #94)
  • Simplified renderers by moving the ErrorBoundary rendering logic into the component itself. Also slightly improved renderer performance in the process. (by @volfpeter in #94)
  • Rewritten how tags work to improve tag creation performance by ~35%. (by @volfpeter in #94)

Breaking changes

These are likely to affect you:

  • html tags can no longer be used for type hints. You should use ComponentType instead.
  • html tags no longer have class utilities like link.css() or meta.charset() for example. The title-case variants have these utility constructors instead, e.g. Link.css() or Meta.charset().
  • WildcardTag is replace by wildcard_tag.

These likely won't affect you:

  • Tag implementations have been moved to tag.py.
  • Creating tags can no longer be done with subclassing (well, it can, just quite differently to how it was done before).
  • TagConfigDict was removed, configuration is now done directly through the Tag() constructor.

Other changes

  • Moved the project from poetry to uv.
  • Updated dev dependencies.
  • Fixed a number of deprecation warnings (most caused by using asyncio and Awaitable instead of the corresponding inspect functions).
  • Added tests for new features.
  • Migrated from mkdocs-material to zensical

Full Changelog: v0.9.0...v0.10.0