Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.6k views
in Q2A Core by

How to delete JavaScript and CSS .Google PageInsights says that these codes hide smth

http://site.com/qa-content/jquery-1.7.2.min.js

http://site.com/qa-content/qa-page.js?1.6.3

2 Answers

0 votes
by

Don't mind what Google says. If you remove the JS Q2A will not work. The first JS is jQuery, you can download it yourself if you don't trust it. The second JS file handles most of the UI stuff that interacts with the server by means of AJAX, for example, performing an upvote on a question without refreshing the whole page.

If you still distrust these files, of course, you can see the code for yourself, but, as I said before, Q2A depends on them so removing them means Q2A will not work.

by
So then Can I move them from <head> to somewhere else?.  for example to bottom of the body section. I've analysed some very SEO friendly websites and found out that  they do not have JS and CSS at the head section.
by
edited by
I have already proposed that: https://github.com/q2a/question2answer/pull/30 . Read Scott's reply.
0 votes
by

https://developers.google.com/speed/docs/insights/BlockingJS

My opinion may be incorrect. However, we may not be able to deal with that matter in current Q2A.

Reasons:

  1. It may not be realistic to add inline jquery... ?
  2. Displaying page will be blocked by reading of script files even if we move script tag to the last of the body.
  3. Now, base theme is HTML4 not HTML5. >> we cannot use "async" attribute in script tag

Reference:

I welcome the opinion of users knowing a lot about HTML and script action.

by
I don't know much about this but here are my 2 cents.

It all depends on what "that matter" means. When it comes to SEO, if scripts on the head result in lower site rating then it doesn't matter if the scripts are blocking or not, that is just how SEO likes them. (I'm talking about SEO because Sardor mentioned it but I don't know much about it).

Now, if what you mean with "that matter" is blocking or non-blocking JS then what you're talking about HTML5 is correct. However, the advantage of having the <script> tags at the bottom comes from a different perspective which basically is: "Load the HTML and CSS first and then load the behaviour". That way, the user can see something (eg: upvote/downvote buttons) and while the user interprets the rendered page and moves the pointer to the action he/she wants to perform then usually JS files have already been downloaded and executed. If the user was faster than the download and execution of the JS files then the action will not take place.

So to summarize, there is a tradeoff on having the script tags on the head and at the end of the body and, IMO, it fully depends on what the JS files do (adding behavior to components or styling) and the server's performance (having script tags on the head on slow servers might result in pages frozen displaying no content for some milliseconds/seconds).

PS: I've seen an attempt to turn v1.7 into HTML5 but I haven't taken a deep look at it (so far I've seen the <!DOCTYPE html> tag but not much more).
...