Skip to content

switchers.js not compatible with Sphinx 6 / requires jQuery #159

@hugovk

Description

@hugovk
  1. Open https://docs.python.org/3.12/ and check the language and version switchers are shown in the header:

image

  1. Check the footer: "Created using Sphinx 4.5.0."
  2. Open https://docs.python.org/3.13/ and see the switchers are not shown:

image

  1. Check the footer: Created using Sphinx 6.2.0."
  2. Check the browser console:
switchers.js:168 Uncaught ReferenceError: $ is not defined
    at switchers.js:168:3
    at switchers.js:182:3

This is because Sphinx 6 removed jQuery:

#7405: Removed the jQuery and underscore.js JavaScript frameworks.

These frameworks are no longer be automatically injected into themes from Sphinx 6.0. If you develop a theme or extension that uses the jQuery, $, or $u global objects, you need to update your JavaScript to modern standards, or use the mitigation below.

https://www.sphinx-doc.org/en/master/changes.html#release-6-0-0-released-dec-29-2022 has a couple of options on how to re-add jQuery, but it would be better rewrite https://github.com/python/docsbuild-scripts/blob/main/templates/switchers.js to use vanilla JavaScript.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions