This pattern of a having code in one language generate a static JSON 'spec' for a figure for rendering in Javascript is very widespread actually... We have Plotly wrappers in Python, R, and Julia and the community has made many others e.g. Scala, F#, Rust, .NET, C++ I believe even!
This is the same approach used by non-Plotly systems like Bokeh in Python (and at one time in R?), Highcharter in R (targets the Highcharts Javascript library) and Altair in Python (targets the Vega-Lite Javascript library).
One of the major advantages of this approach is that it makes it easy to move from visualizing data locally to embedding these same visualizations into a web application, which is what Plotly's Dash library is for: https://dash.plotly.com/