Created by: jamesplease
View the changes here
- Wraps Mathjax in an IIFE
- Throws an error when the browser isn't supported
Why?
This change gets rid of this line, which are two closing brackets that require users to go to the top of the file to see where they begin. Yikes. By wrapping things in an IIFE we can keep those two 'checks' where the belong – self-contained at the top of the file. It makes the code a bit more readable, I think.
On the error: emitting the error when the browser isn't supported is being more communicative than just silently failing. I think this is important enough of a failure to be error-worthy, but maybe you disagree and prefer the silent failure. Nbd either way.
Why an IIFE? For this PR it might not seem that necessary. It does let us return from the IIFE on the second conditional at the top, which is super nice, though. What's more important is the direction this can take the library. It's a small step toward supporting a UMD implementation, which could come next.
I admit I didn't test this. It's really just a PR to see if you guys are interested in these sorts of changes toward the broader goal of cleaning up the lib.
Note: Because I indented the whole file Github won't show the changes unless you tell it to ignore whitespaces.