-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move javascript back to head #545
Changes from 1 commit
433ce2f
2a47e06
0614961
cc0a99b
9744003
6cd5a15
25b9abe
c43d0b0
1f47e23
0bff615
bdef03a
d9c1668
8e00c50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,16 +28,47 @@ | |
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html"/> | ||
{% endif %} | ||
|
||
{# CSS #} | ||
|
||
{# OPENSEARCH #} | ||
{# Javascript -- Keepin in head #} | ||
{% if not embedded %} | ||
{% if use_opensearch %} | ||
<link rel="search" type="application/opensearchdescription+xml" title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}" href="{{ pathto('_static/opensearch.xml', 1) }}"/> | ||
<script type="text/javascript"> | ||
var DOCUMENTATION_OPTIONS = { | ||
URL_ROOT:'{{ url_root }}', | ||
VERSION:'{{ release|e }}', | ||
LANGUAGE:'{{ language }}', | ||
COLLAPSE_INDEX:false, | ||
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}', | ||
HAS_SOURCE: {{ has_source|lower }}, | ||
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}' | ||
}; | ||
</script> | ||
{%- for scriptfile in script_files %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a comment saying not to use this? Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The extension will have to be updated. Currently There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe @ericholscher is planning to remove many of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to support people using them, since a lot of people use them. If we get to a point where Sphinx doesn't pass them anymore, then we can stop supporting them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There seems to be some confusing here. Note that this WILL be removed by sphinx 2.0.0 so we should add a comment in the html for people reading through the code so they know what the better option is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the builder yes, I am still a little unsure of what direction sphinx will really go with this, so I'll ask. Since this does not affect this PR we can come back to this later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See this thread for why this is deprecated. So basically it can only be used for reading, not writing to unless through the sphinx app API. So we can keep Thread https://groups.google.com/forum/#!topic/sphinx-dev/bvnF6Grw224 |
||
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script> | ||
{%- endfor %} | ||
|
||
{# RTD hosts this file, so just load on non RTD builds #} | ||
{% if not READTHEDOCS %} | ||
<script type="text/javascript" src="{{ pathto('_static/js/theme.js', 1) }}"></script> | ||
{% endif %} | ||
<script src="{{ pathto('_static/js/modernizr.min.js', 1) }}"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You definitely want modernizr before loading 3rd party scripts ( |
||
<script type="text/javascript"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can probably stay in the footer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to Paul Irish, in the footer is the way to go for performance, unless you target IE6-8 with the html5shiv: Modernizr/Modernizr#878 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment was directed towards the script below the modernizr link There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoops. Yes, that should be at the bottom. It is the code that starts the theme JS logic and should be run when the page (or at least the toctree) is complete. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Putting JS in the footer is definitely better for performance in general but anything required for rendering should be in the header. Not that we necessarily have to follow their lead, but Alabaster and the Spinx Basic theme (which Alabaster extends) both put JS in the head. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do think that attempting to have consistency across themes isn't a bad thing though. |
||
jQuery(function () { | ||
{% if theme_sticky_navigation|tobool %} | ||
SphinxRtdTheme.Navigation.enableSticky(); | ||
{% else %} | ||
SphinxRtdTheme.Navigation.enable(); | ||
{% endif %} | ||
}); | ||
</script> | ||
|
||
{% endif %} | ||
{# OPENSEARCH #} | ||
{%- if use_opensearch %} | ||
<link rel="search" type="application/opensearchdescription+xml" | ||
title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}" | ||
href="{{ pathto('_static/opensearch.xml', 1) }}"/> | ||
{%- endif %} | ||
{%- endif %} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: the |
||
{# CSS #} | ||
{# RTD hosts this file, so just load on non RTD builds #} | ||
{% if not READTHEDOCS %} | ||
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" /> | ||
|
@@ -80,10 +111,6 @@ | |
{%- endif %} | ||
{%- endblock %} | ||
{%- block extrahead %} {% endblock %} | ||
|
||
{# Keep modernizr in head - http://modernizr.com/docs/#installing #} | ||
<script src="{{ pathto('_static/js/modernizr.min.js', 1) }}"></script> | ||
|
||
</head> | ||
|
||
<body class="wy-body-for-nav"> | ||
|
@@ -185,40 +212,6 @@ | |
</div> | ||
{% include "versions.html" %} | ||
|
||
{% if not embedded %} | ||
|
||
<script type="text/javascript"> | ||
var DOCUMENTATION_OPTIONS = { | ||
URL_ROOT:'{{ url_root }}', | ||
VERSION:'{{ release|e }}', | ||
LANGUAGE:'{{ language }}', | ||
COLLAPSE_INDEX:false, | ||
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}', | ||
HAS_SOURCE: {{ has_source|lower }}, | ||
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}' | ||
}; | ||
</script> | ||
{%- for scriptfile in script_files %} | ||
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script> | ||
{%- endfor %} | ||
|
||
{% endif %} | ||
|
||
{# RTD hosts this file, so just load on non RTD builds #} | ||
{% if not READTHEDOCS %} | ||
<script type="text/javascript" src="{{ pathto('_static/js/theme.js', 1) }}"></script> | ||
{% endif %} | ||
|
||
<script type="text/javascript"> | ||
jQuery(function () { | ||
{% if theme_sticky_navigation|tobool %} | ||
SphinxRtdTheme.Navigation.enableSticky(); | ||
{% else %} | ||
SphinxRtdTheme.Navigation.enable(); | ||
{% endif %} | ||
}); | ||
</script> | ||
|
||
{%- block footer %} {% endblock %} | ||
|
||
</body> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the second half of this comment. Feels silly.