can startup's ready() be async?

15 views
Skip to first unread message

Peter Krautzberger

unread,
Oct 11, 2020, 11:19:36 AM10/11/20
to mathj...@googlegroups.com
Hi,

I've been playing with building client-side extensions and I've been wondering about the ready function. I needed it to be async, e.g.,

      MathJax = {
        tex: { packages: { '[+]': ['myextension'] } },
        startup: {
          async ready() {
            ....// something async
            MathJax.startup.defaultReady();
          },
        },
      };

and that didn't seem to cause any issues.

Was I just lucky with my particular use case or is this generally ok?

Best,
Peter.

Davide Cervone

unread,
Oct 11, 2020, 6:46:44 PM10/11/20
to mathj...@googlegroups.com
Peter:

Can you be more specific about what the asynchronous actions are?  It might help me to tell you what the best approach is for that.

There are several places that you can use promises to cause MathJax to wait for your actions, but this is not one of them.  (It could be made to be one, but it currently isn't.)    I will try to write up some possibilities for you this week, but am not able to do so tonight.

Best!

Davide



--
You received this message because you are subscribed to the Google Groups "MathJax Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-dev/CABOtQmH3e6rymwmz7HJb14CuufYvFvtWB%3DwqyWnGq9tyaaA-kA%40mail.gmail.com.

pe...@krautzource.com

unread,
Oct 12, 2020, 3:59:33 PM10/12/20
to MathJax Development
Hi Davide,

For a side project, I was trying to enable a custom extension for client-side use.

I had started with your example for building the \img extension in an inline configuration. So I thought I could just move the body of my extension to an ES module and have startup's ready do a dynamic import of the module.

That seemd fairly natural overall but required asynchronicity. Here's an example https://krautzource.github.io/mathjax-aria-label/

I've since found the docs on how to build an extension with webpack so I'll have a closer look at making that work.

Anyway, now that I know there's an official way, I should be all set.

Best,
Peter

Reply all
Reply to author
Forward
0 new messages