nuxt-modules / og-image

Generate OG Images with Vue templates in Nuxt.
https://nuxtseo.com/og-image
417 stars 28 forks source link

feat: Zero Runtime mode #261

Closed harlan-zw closed 2 months ago

harlan-zw commented 2 months ago

๐Ÿ”— Linked issue

https://github.com/nuxt-modules/og-image/issues/210

https://github.com/nuxt-modules/og-image/issues/162 (workaround) https://github.com/nuxt-modules/og-image/issues/193 (workaround)

โ“ Type of change

๐Ÿ“š Description

There are cases where we want to deploy our Nuxt app as a server-side app and we want OG Images, but we don't want to host live runtime OG images due to the performance cost.

For this, we introduce the zeroRuntime config which will ensure all tree-shakable OG image code is removed for the final server output.

While the mode is called "Zero Runtime", there is still a slight overhead of ~30kb on the server build which is coming from:

Benchmarks

Without OG Image

Nitro: 274kb

Client: 209kb

With OG Image - Default

Nitro: 1.6mb

Client: 211kb

With OG Image - Zero Runtime

Nitro: 306kb

Client: 210kb

:warning: Community Templates

When using zeroRuntime none of the community templates will be available in your final build, you must copy+paste any community template that you wish to use into your components/OgImage folder.