diff --git a/docs/sphinx_rtd_theme_chm_friendly/layout.html b/docs/sphinx_rtd_theme_chm_friendly/layout.html
index 1b75e2d8a..109e8ef84 100644
--- a/docs/sphinx_rtd_theme_chm_friendly/layout.html
+++ b/docs/sphinx_rtd_theme_chm_friendly/layout.html
@@ -193,20 +193,27 @@
{% if not embedded %}
-
- {%- for scriptfile in script_files %}
-
- {%- endfor %}
+ {% if sphinx_version >= "1.8.0" %}
+
+ {%- for scriptfile in script_files %}
+ {{ js_tag(scriptfile) }}
+ {%- endfor %}
+ {% else %}
+
+ {%- for scriptfile in script_files %}
+
+ {%- endfor %}
+ {% endif %}
{# RTD hosts this file, so just load on non RTD builds #}
{% if not READTHEDOCS %}