diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html
index 5f755a2a2..a8ac2d01c 100644
--- a/sphinx_rtd_theme/layout.html
+++ b/sphinx_rtd_theme/layout.html
@@ -191,20 +191,28 @@
{% if not embedded %}
-
- {%- for scriptfile in script_files %}
-
- {%- endfor %}
+ {# XXX Sphinx 1.8.0 made this an external js-file, quick fix until we refactor the template to inherert more blocks directly from sphinx #}
+ {% if sphinx_version >= "1.8.0" %}
+
+ {%- for scriptfile in script_files %}
+ {{ js_tag(scriptfile) }}
+ {%- endfor %}
+ {% else %}
+
+ {%- for scriptfile in script_files %}
+
+ {%- endfor %}
+ {% endif %}
{% endif %}