## Enable latex/mathjax in your post only if needed

- Assuming this is an extension of my earlier mathjax post
- This post contains
`latex`

or`math`

mode symbols.

`mathjax.js`

is loaded from the`default.html`

, even for the post/page- that was not using math/latex symbols it used load
`mathjax.js`

unnecessarily. - 23 HTTP page request vs 4 (with mathjax vs without)
- So, decided to load (mathjax.js) only for post that has math symbols
- Have added custom variable called
`mathjax`

. - But, should remember to set variable to true in post’s front matter

#### _post/2020-04-01-new-post.md

```
---
layout: post
title: Enable latex/mathjax in your post only if needed
tags: [jekyll, latex]
mathjax: true
---
```

#### _layouts/default.html

```
{% if page.mathjax == true %}
{% include mathjax.html %}
{% endif %}
```

See the full post and default html.