Description
Spurred by plotly/dash#880 as it's annoying to have to control script tag ordering in dash.
Currently the docs say MathJax must be loaded before plotly.js, and locales must be loaded after. This is because plotly.js looks for typeof MathJax !== 'undefined'
during script execution, and if it finds MathJax it configures it. Whereas the opposite happens with locales: the script immediately calls Plotly.register
, so it assumes that the Plotly
object exists.
For MathJax we could simply defer this configuration to the first Plotly.plot
call - and set some flag so we don't do it again.
For locales it's a little more complicated, we would have to do something like call Plotly.register
if it exists, otherwise stash the locale in some global like window.PlotlyLocales
(in a way that's compatible with multiple locale scripts), and then during the plotly.js script execution grab these and register them. At first I was thinking of deferring this to the first Plotly.plot
call along with the MathJax config, and that may still work, I just worry people may want to inspect the available locales and would be confused that they don't see the right ones.