# Vega Plugins Plugins extend Vega with custom functions, transforms, and other chart features. Use one when your specification needs an extension that Vega does not include. The [Vega extensibility API](https://vega.github.io/vega/docs/api/extensibility/) lists the registration functions a plugin can call. :::{warning} A plugin is executable JavaScript. Load plugin files and URLs only from sources you trust. Do not accept caller-supplied plugins on a public service unless you have decided to accept that risk ::: ## Create a Plugin A plugin is a JavaScript ECMAScript module (ESM) whose default export is a function. VlConvert calls that function with the Vega module when a worker starts, before any specification is compiled or parsed. Save this example as `double-value.js`: :::{dropdown} double-value.js :open: ```{literalinclude} /_examples/double-value.js :language: javascript ``` ::: Save this Vega-Lite specification: :::{dropdown} chart.vl.json :open: ```{literalinclude} /_examples/plugin-demo.vl.json :language: json ``` ::: The `calculate` transform can now call `doubleValue`. ## Register the Plugin List startup plugins in `VlcConfig`: ```rust use vl_convert_rs::{PngOpts, VlcConfig, VlConverter, VlOpts}; let spec = std::fs::read_to_string("chart.vl.json")?; let converter = VlConverter::with_config(VlcConfig { vega_plugins: vec!["./double-value.js".to_string()], ..Default::default() })?; let output = converter .vegalite_to_png(spec, VlOpts::default(), PngOpts::default()) .await?; std::fs::write("chart.png", output.data)?; ``` The registered `doubleValue` function doubles the source values before Vega draws these bars: ```{vl-chart} /_examples/plugin-demo.vl.json :vega-plugin: /_examples/double-value.js :alt: Two bars with the source values doubled to four and ten ``` Plugins can also come from HTTPS URLs or inline source, and a plugin can import other modules. See {doc}`../advanced/plugin-loading` for loading modes, import allowlists, prebundling, and caller-supplied plugins, and {doc}`security` for the wider trust model.