Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
862 views
in Q2A Core by
How can I move JS files to the bottom? Is there any plugin or way to do this?
Q2A version: 1.6.2
by
To the bottom of... what? You mean closer to the </body> HTML tag? Also, you mean all of the JS files?
by
Google Pagespeed Test says that I have to move the JS files to the bottom of the page (Speed Score : 70/100)

http://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fnewandroidnews.net%2Findex.php%2F1%2Florem-ipsum-test-title

1 Answer

+2 votes
by
selected by
 
Best answer

Ok, I have already proposed that some time ago. You can see the pull request here: https://github.com/pupi1985/question2answer/commit/45a66c6437f42afbf608980b0f92df39ce1451a4

You can move the $this->body_script(); right before the  $this->output('</body>'); in qa-theme-base.php. This would be considered as a core hack.

Or you can override the body() in your qa-theme.php moving the same line to the bottom. This would be the best approach.

by
I applied but it did not work (.js files still above <body> tag)

I need to move $this->head_script(); bottom of $this->output('</body>');
by
It all depends on where the javascript code is added and that is determined by plugins and themes. If, in your case, javascript code is only output in the head_script() that would do the trick.
by
I moved $this->head_script(); bottom of $this->output('</body>'); and it worked for me, Thank you
...