Skip to content
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

Javascript should go to the bottom #956

Open
thany opened this issue Aug 7, 2015 · 1 comment
Open

Javascript should go to the bottom #956

thany opened this issue Aug 7, 2015 · 1 comment

Comments

@thany
Copy link

thany commented Aug 7, 2015

Currently zenphoto renders javascript near the top of the page, usually just before the </head>. Javascript belong just before the </body>, so the page doesn't remain empty while the javascript is being loaded and being parsed. Especially on mobile devices this is noticable. When corrected, a page will at least begin rendering itself before any javascript may have been loaded. This will make page loads feel faster, and make visitors happier.

Now I know very well that this is up to the theme. And it is. But does it work when I put javascript at the bottom of the page? Maybe, should be tested. And any DOMContentLoaded and/or $(function() {... or other forms of "on document loaded" events are no longer needed, because near the </body> the DOM is guaranteed to have been loaded. So, further removing complexity and potentially increasing speed.

The tricky bit is the name of the filter, and current themes and plugins registering their stuff thinking that it goes to the top. But I'm sure it can be fixed. Or you can just break compatibility - for a good reason, there's no shame in it :)

@acrylian acrylian added this to the 2.0 milestone Aug 8, 2015
@acrylian
Copy link
Member

acrylian commented Aug 8, 2015

We know about that and that is a change for the next big version, too. Although not every JS works at the bottom so that needs to be tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants