Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not load mathjax per page #257

Closed
icecory opened this issue Apr 23, 2018 · 19 comments
Closed

Not load mathjax per page #257

icecory opened this issue Apr 23, 2018 · 19 comments

Comments

@icecory
Copy link

icecory commented Apr 23, 2018

{% if not theme.math.per_page or (is_index_has_math or page.mathjax) %}

i think this line should be
{% if theme.math.per_page or (is_index_has_math or page.mathjax) %}

@ivan-nginx
Copy link
Member

ivan-nginx commented Apr 23, 2018

U suggest not load MJ per page by default?

hexo-theme-next/_config.yml

Lines 423 to 430 in 1e8670b

# Math Equations Render Support
math:
enable: false
# Default(true) will load mathjax/katex script on demand
# That is it only render those page who has 'mathjax: true' in Front Matter.
# If you set it to false, it will load mathjax/katex srcipt EVERY PAGE.
per_page: true

@wafer-li, guys, any comments about it?

@sli1989
Copy link
Collaborator

sli1989 commented Apr 23, 2018

We had discussed before.
And I prefer to change too.
He seems busy on exam this year.


per page: true mean per page loads math literally. However, If you set it to false, it will load mathjax/katex srcipt EVERY PAGE.

@ivan-nginx
Copy link
Member

So, maybe need to rename per_page on something like on_demand?

@sli1989
Copy link
Collaborator

sli1989 commented Apr 23, 2018

I think it can be done just reverting some logic, but may result in breaking change (can't be compatible).

@ivan-nginx
Copy link
Member

It's will be breaking change if we change here anything. So, to prevent confuse users rename this option on more comfortable value will be best.

@icecory
Copy link
Author

icecory commented Apr 23, 2018

sorry, my next version is a little old, not have this comment ,

Default(true) will load mathjax/katex script on demand
That is it only render those page who has 'mathjax: true' in Front Matter.
if you set it to false, it will load mathjax/katex srcipt EVERY PAGE.

so i think per_page is meaning load every page , so i set this false,
my mathjax cdn is too slow ,mathjax.js also too large( sometimes loading 7-8s ) , making loading totally slow.

@oracleyue
Copy link

oracleyue commented Apr 24, 2018

a bug for me (when I switch to use the theme from hexo-next repo)

(I am a newbie, just ignore me if this makes no sense)

If I set per_page to true, the hexo-math (using MathJAX) fails to show equations (it shows the latex source.)

@greedyboy
Copy link

I think rename per_page is usefull, such as per_page_manual_control,per_page_on_deand

@StoneMa
Copy link

StoneMa commented Apr 25, 2018

when per page is set to true, you need to use mathjax:true in each md to enable mathjax.
there should set mathjax tag true in your pages, like this:
image

@oracleyue
Copy link

@StoneMa Ah, I get the meaning of per_page, thanks! To avoid the legacy users, alternatively, you may clarify it in the comments. For example, “when per page is set to true, you need to use mathjax:true in each md to enable mathjax.” Something like this. FYI.

@oracleyue
Copy link

It already had such comments. Excuse me. I will just upgrade my next.

@xu-song
Copy link
Contributor

xu-song commented May 3, 2018

Maybe we can set default value as false, to make sure it works by default.

per_page: false

@panqiincs
Copy link

panqiincs commented May 17, 2018

Just my opinion. It's better if the post file is independent from the theme, or, every time we changes the theme, we need to modify the post file too.

So, is there a mechanism that can detect equation expressions in the post file? Can it be implemented in NexT not Hexo?

@ivan-nginx
Copy link
Member

So, is there a mechanism that can detect equation expressions in the post file? Can it be implemented in NexT not Hexo?

I think about this too with other guys and for now we can't find something like ready-to-work math autodetection. And actually, this can be implement via internal JS libraries in NexT, but here may be a little trouble: nobody knows, on how much lower will be the speed of content generation then. But idea is nice, thank's for opinion, @panqiincs.


per_page will be true for now in accordance with other sinilar default settings:

hexo-theme-next/_config.yml

Lines 449 to 455 in 6051571

math:
enable: false
# Default(true) will load mathjax/katex script on demand
# That is it only render those page who has 'mathjax: true' in Front Matter.
# If you set it to false, it will load mathjax/katex srcipt EVERY PAGE.
per_page: true

hexo-theme-next/_config.yml

Lines 479 to 485 in 6051571

pdf:
enable: false
# Default(true) will load PDFObject/PDF.js script on demand
# That is it only render those page who has 'pdf: true' in Front Matter.
# If you set it to false, it will load PDFObject/PDF.js srcipt EVERY PAGE.
per_page: true

But later we will back to this question again...

@stevenjoezhang
Copy link
Contributor

stevenjoezhang commented Mar 6, 2019

So, is there any good way to judge whether there is a math formula in the page? per_page is really a a misleading option, and mathjax: true in front matter is not cool

@ivan-nginx
Copy link
Member

Need to ask someone who often work math. @sli1989?

@sli1989
Copy link
Collaborator

sli1989 commented Mar 7, 2019

yeah, I talked about this last year, and I prefer to change the logic too.
Doing this introduces the breaking change, so this section remain the status quo without necessarily command.

@stevenjoezhang stevenjoezhang changed the title not Load mathjax per page Not load mathjax per page Apr 16, 2019
@stevenjoezhang stevenjoezhang pinned this issue Jul 12, 2019
@ivan-nginx ivan-nginx mentioned this issue Jul 17, 2019
33 tasks
@stevenjoezhang
Copy link
Contributor

stevenjoezhang commented Aug 9, 2019

Two different solutions:

@1v9 1v9 unpinned this issue Aug 29, 2019
@stevenjoezhang
Copy link
Contributor

stevenjoezhang commented Sep 1, 2019

My opinion is to keep it as is. Regular expressions are not always accurate (depending on the renderer).
hexo-filter-mathjax plugin added to awesome-next list.

Update: see also next-theme/hexo-filter-mathjax#18

Option renamed in next-theme/hexo-theme-next@a3dcac5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests