MathJax

mathjax.org

Official Implementation

HTML<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    showMathMenu: false
  });
</script>

Simple Solution

Remove the script tags from the head and add the following coffeescript to your application:

COFFEESCRIPT$ ->
  loadMathJax()
  $(document).on 'page:load', loadMathJax

loadMathJax = ->
  window.MathJax = null
  $.getScript "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML", ->
    MathJax.Hub.Config
      showMathMenu: false

Advanced Solution (with AJAX caching)

  1. Remove the script tags from the head.

  2. Define this classes somewhere in your application's JS:

    COFFEESCRIPTclass MathJax
      constructor: (@options) ->
        @bind()
    
      load: =>
        window.MathJax = null
        @_fetch().done =>
          window.MathJax.Hub.Config @options
    
      bind: ->
        $ => @load()
        $(document).on 'page:load', @load
    
      unbind: ->
        $(document).off 'page:load', @load
    
      # private
    
      _fetch: ->
        $.ajax
          dataType: 'script'
          cache: true
          url: "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
  3. Add this line to your application's JS (after the class has been defined) to initialize MathJax

    COFFEESCRIPTnew MathJax
      showMathMenu: false

Related Issues: #16

Credit: Nick Reed


All solutions should be considered unofficial. There is no guarantee that a given solution will work with your application. If you find that a solution is insufficient, please let me know by submitting an issue on Github.