Selective inclusion of Javascript

51 views
Skip to first unread message

Stefano David

unread,
Aug 31, 2020, 4:49:56 AM8/31/20
to sphinx-users
Hi all,

We all know we can include JS files using app.add_js_file. This however inserts the JS in *every* html page. I was wondering if there is a proper way to do so or if someone has come up with a possible solution.

I think this could be useful in many scenarios. Think for example of a web site with lots of mathjax code in only one page: by using add_js_file, the js would be included in all pages, although not necessary.

More generally, if you use an extension that adds its own JS, that JS will be added to all pages, although it is necessary only in pages on which you use the extension's functionality.

Thanks for any thoughts!
Stefano

Komiya Takeshi

unread,
Sep 5, 2020, 6:00:19 AM9/5/20
to sphinx...@googlegroups.com
Hi,

I have a similar report: https://github.com/sphinx-doc/sphinx/issues/6241
But I don't have time to work on it.
Any contributions are welcome :-)

Thanks,
Takeshi KOMIYA

2020年8月31日(月) 17:50 Stefano David <ste...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/5d7540f6-f206-4949-964c-04a72d9fc5f7n%40googlegroups.com.

Anton Akhmerov

unread,
Sep 5, 2020, 6:06:15 AM9/5/20
to sphinx-users
Hi Takeshi,

Would you have some pointers or suggestions as to how a possible implementation could work?

Best,
Anton

Komiya Takeshi

unread,
Sep 5, 2020, 7:11:40 AM9/5/20
to sphinx...@googlegroups.com
At present, I don't have a good idea about the new API. Any proposal
is welcome :-)

2020年9月5日(土) 19:06 Anton Akhmerov <i...@antonakhmerov.org>:
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/4fef83ab-715c-49fa-a0eb-af7709321fdan%40googlegroups.com.

Daniel Scott

unread,
Nov 25, 2020, 10:32:41 PM11/25/20
to sphinx...@googlegroups.com
--
Reply all
Reply to author
Forward
0 new messages