diff --git a/sphinx/application.py b/sphinx/application.py
index 5349c36ad42..b2a4c0d53fa 100644
--- a/sphinx/application.py
+++ b/sphinx/application.py
@@ -1461,14 +1461,38 @@ def add_js_file(
Example::
app.add_js_file('example.js')
- # =>
+ # =>
app.add_js_file('example.js', loading_method='async')
- # =>
+ # =>
app.add_js_file(None, body="var myVariable = 'foo';")
# =>
+ .. note::
+
+ For the file to be included in the output, it must be present in
+ the ``_static`` directory at build time.
+ Extension developers should use :meth:`add_static_dir` to register
+ a directory whose contents will be copied to ``_static``.
+ Site authors can place files into a directory listed in
+ :confval:`html_static_path` instead.
+
+ .. tip::
+
+ Site authors (as opposed to extension developers) who wish to add
+ custom JavaScript files may find it easier to use the
+ :confval:`html_js_files` configuration value in combination with
+ :confval:`html_static_path`, rather than writing an extension.
+
+ .. note::
+
+ Files registered by extensions can be overridden by site authors
+ by placing a file with the same name into their
+ :confval:`html_static_path`. Note that this may not work in all
+ cases; see `#12096 `__
+ for details.
+
.. list-table:: priority range for JavaScript files
:widths: 20,80
@@ -1498,6 +1522,9 @@ def add_js_file(
.. versionchanged:: 4.4
Take loading_method argument. Allow to change the loading method of the
JavaScript file.
+ .. versionchanged:: 7.1
+ A CRC32 checksum is appended as a query parameter to local asset
+ URIs (e.g. ``?v=a1b2c3d4``) for cache-busting purposes.
"""
if loading_method == 'async':
kwargs['async'] = 'async'
@@ -1527,16 +1554,41 @@ def add_css_file(self, filename: str, priority: int = 500, **kwargs: Any) -> Non
Example::
app.add_css_file('custom.css')
- # =>
+ # =>
app.add_css_file('print.css', media='print')
- # =>
app.add_css_file('fancy.css', rel='alternate stylesheet', title='fancy')
- # =>
+ .. note::
+
+ For the file to be included in the output, it must be present in
+ the ``_static`` directory at build time.
+ Extension developers should use :meth:`add_static_dir` to register
+ a directory whose contents will be copied to ``_static``.
+ Site authors can place files into a directory listed in
+ :confval:`html_static_path` instead.
+
+ .. tip::
+
+ Site authors (as opposed to extension developers) who wish to add
+ custom CSS files may find it easier to use the
+ :confval:`html_css_files` configuration value in combination with
+ :confval:`html_static_path`, rather than writing an extension.
+
+ .. note::
+
+ Files registered by extensions can be overridden by site authors
+ by placing a file with the same name into their
+ :confval:`html_static_path`. Note that this may not work in all
+ cases; see `#12096 `__
+ for details.
+
.. list-table:: priority range for CSS files
:widths: 20,80
@@ -1570,6 +1622,10 @@ def add_css_file(self, filename: str, priority: int = 500, **kwargs: Any) -> Non
.. versionchanged:: 3.5
Take priority argument. Allow to add a CSS file to the specific page.
+
+ .. versionchanged:: 7.1
+ A CRC32 checksum is appended as a query parameter to local asset
+ URIs (e.g. ``?v=a1b2c3d4``) for cache-busting purposes.
"""
logger.debug('[app] adding stylesheet: %r', filename)
self.registry.add_css_files(filename, priority=priority, **kwargs)