top of page
Search

Getting MathJax to work with Wix

  • ZackW
  • Aug 20, 2022
  • 3 min read

Updated: Aug 12, 2025

Update August 12th, 2025: My original code has stopped working - see this github issue for an updated solution: https://github.com/anishhdiwan/wix_mathjax_tutorial/issues/2

This was annoying enough to write down. Someone else has already started on the topic, luckily, but I wasn't super happy with having to embed HTML every time I wanted to include an equation on my blog. Both services, AsciiMath and MathJax try and make it extremely easy for you to use their program. Wix of course, wants to go and screw it up for ya. Part of the issue, as already pointed out by Nate Davis, is that Wix seems to like holding on the '\' character and refuses to let it go. I'm not sure why, but AsciiMath's approach wasn't working for me when I was trying to include their script in a site-wide script. Might be the next thing to figure out, but for now I'm just trying to get MathJax working since it seems the closest.


Actually, as it turns out, MathJax includes AsciiMath as sort of an interface now. So, all I have to worry about is getting MathJax working. This was really a huge pain, and took most of the day to figure out. The basic isssue is that Wix sort of seems to reload the text of a page even after it's loaded once or twice, I have no idea why. This messes with how equations are created, since MathJax will see them the first time they are loaded, convert them to a pretty equation, and forget about them. I tried a number of approaches to try and get MathJax to load later, once all the operations were done, and that's what took the longest time. Wix provides some neat sort of simplified Javascript api for you, but doesn't give you any tools to work with scripts through that system. Your only option to work with DOM-capable scripts is to include them in the header or body of your HTML.


One thing I did discover, and I'm very proud of this, is you can send a message event from Wix's "Velo" API and recieve it from a normal javascript script. I used this to try and use their API "onReady" event to trigger the loading of MathJax, which was later than all the other approaches I had tried but still caused the equations to disappear after a second once the page loaded a second time. Ultimately I stumbled upon "MutationObservers", and decided to use them to brute force the issue. Now, I have a script simply listening for updates to the blog post itself and will tell MathJax to try re-typesetting each time there's an update. Inefficient? Maybe. Does it work? Seems to!


`sum_(i=1)^n i^3=((n(n+1))/2)^2`


These can be put inline (`x = 1/y`), and aren't iframe'd HTML pages like the other approach takes. I'm not sure how far I can take this, since I'm not super familiar with AsciiMath's interface, but it seems quite powerful for just blog post stuff. Hopefully you'll be seeing more content with fancy equations soon.


Mutation Observers

This was a great help, and I basically just used their example code: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver. It took me a minute to remember that I had to wait for the blog post to load in the first place, and the observer was error'ing and complaining it couldn't find anything by the requested id. Oops.


The code

This isn't the prettiest formatting of it, but I'm sure that if someone finds this post they would be extremely annoyed if I didn't include anything meaningful about my solution besides a description.

And this is what the two scripts look like in the custom code section. Note that I have both of them set to only run on blog posts.

More Math!

Okay so it'd be a bit sad if I didn't stretch this out a bit more. The AsciiMath website is quite short and has a basic overview of all the stuff you can do. What about trying some integrals?


`int_1^10 e^{2x} dx`


Seems to work alright! One annoying thing is that if I preview the results in the same window, the editor starts to bug out and you have to reload it. A problem for another time, I think. Anyone know this one? Hopefully I copied it right !


`X(k) = sum_(n=0)^(N-1) x_n e^((−2πikn)/N)`


It seems to even take into account the font size and the alignment of the original text, which is really nice.



 
 
 

53 Comments


jordan83353
a day ago

Việc tích hợp MathJax vào một nền tảng như Wix thực sự là một thử thách kỹ thuật không nhỏ đối với những người không chuyên về lập trình như tôi. Trong lúc loay hoay tìm kiếm các giải pháp trên diễn đàn, tôi từng vô tình thấy ai đó thảo luận về việc cấu hình giao diện hiển thị cho các cổng game như tg88 cũng gặp phải những lỗi hiển thị tương tự khi không đồng bộ được mã nguồn. Có lẽ việc xử lý các script nặng trên nền tảng web luôn đòi hỏi sự kiên nhẫn và thử nghiệm liên tục cho đến khi mọi thứ chạy ổn định. Bài viết đã hướng dẫn khá chi tiết…

Like

jordan83353
a day ago

Việc cài đặt MathJax để hoạt động ổn định trên nền tảng Wix thực sự là một thử thách đối với người không chuyên về kỹ thuật lập trình. Tôi nhớ lại cảm giác loay hoay khi giúp một người bạn tìm hiểu về cấu trúc của các trang web giải trí tương tự như alo789, nơi mà các đoạn mã thường được ẩn giấu rất kỹ để tối ưu hóa trải nghiệm người dùng cuối. Sự phức tạp trong việc nhúng mã nguồn vào hệ thống đôi khi khiến người ta nản lòng, nhưng kết quả đạt được sau khi mọi thứ chạy trơn tru lại rất xứng đáng. Bài viết đã hướng dẫn chi tiết từng bước, giúp…

Like

jordan83353
a day ago

Việc cài đặt MathJax trên Wix đúng là một thử thách đối với người không chuyên về lập trình như tôi. Tôi đã loay hoay khá lâu trước khi tìm thấy hướng dẫn này, và nó giải quyết được phần nào sự bối rối trong việc hiển thị các công thức toán học phức tạp trên giao diện web. Đôi khi, trong lúc tìm kiếm giải pháp kỹ thuật, tôi vô tình thấy những diễn đàn thảo luận về giao diện của các trang như cm88, nơi mà người ta cũng bàn về việc tối ưu hóa hiển thị sao cho thân thiện và dễ nhìn hơn với người dùng. Sự tương đồng trong việc ưu tiên trải nghiệm người…

Like

jordan83353
2 days ago

Đang định tìm cổng game online để chơi cuối tuần nên mình vào xem i9betvi xem sao. Ấn tượng đầu tiên là số lượng trò chơi hiển thị rất nhiều, cảm giác như lạc vào một khu giải trí thu nhỏ vậy. Mình có bấm vào xem thử mấy sảnh thể thao và sảnh bài, thấy thông tin tỷ lệ được cập nhật liên tục ngay tại lobby chính. Phần khuyến mãi cũng hiện lên khá rõ ràng, tuy nhiên mình thường ít khi quan tâm kỹ mấy cái này vì sợ điều kiện phức tạp. Bản thân mình chỉ cần tìm chỗ nào thao tác đơn giản, thông tin minh bạch là thấy ổn rồi. Mình cũng lướt qua phần…

Like

jordan83353
2 days ago

Vừa đọc xong bài viết về cách làm cho MathJax hoạt động trên Wix, mình thấy khá thú vị vì đây là một vấn đề mà không ít người dùng Wix có nhu cầu giải quyết. Khi đọc, mình nhớ đến mấy lần lang thang trên web và tìm cách để hiển thị công thức toán học một cách chính xác, có lúc thấy ai đó nhắc đến 79king5v như một trang tham khảo công nghệ khá hữu ích. Mình thì không phải dân lập trình hay thiết kế web chuyên nghiệp, nên những hướng dẫn này như một kiểu mở rộng tầm hiểu biết của mình về cách kết hợp các công cụ kỹ thuật số khác nhau. Đọc bài…

Like

©2022 by NeohertzEE. Proudly created with Wix.com

bottom of page