1

I have a <head> tag with a lot of scripts, converted a website from 7 pages into 1 and so now the 1 page is doing the work of 7. There is about a 2 - 30 second load time and I am in no way going to make this optimized for mobile.

Writing raw html doesn't seem to show until the page is fully loaded, so writing 'Loading, please wait...' doesn't appear until after the fact.

How does one display a loading comment before the head tag finishes loading?

Lairinus
  • 110
  • 10
  • 2
    Consider adding `defer` to the scripts. Keep in mind that scripts have to be able to deal with this asynchronicity. – Halcyon Oct 22 '15 at 16:08
  • Here's more: http://stackoverflow.com/questions/436411/where-is-the-best-place-to-put-script-tags-in-html-markup – Chris Lear Oct 22 '15 at 16:14
  • 2
    Can you move the scripts to the bottom of the page before the closing `

    ` tag rather than the `

    `?

    – BadHorsie Oct 22 '15 at 16:20
  • 1
    Are you loading scripts in via the src attribute? If your javascript is inline you can't use async and only some browsers (?) support defer. For inline javascript the only option is move the scripts to the bottom of body. – James Oct 22 '15 at 16:35

1 Answers1

1

Off the bat you have three simple options. You could move scripts out of the head, or you could defer the scripts, or you could async the scripts.

WesW
  • 128
  • 1
  • 9
  • 1
    If he moves the scripts out of the head, he should specifically move them to the bottom of the ``. – Barmar Oct 22 '15 at 16:33
  • Thank you for your response. I now have a working loading prompt that works after moving my scripts out of the head tag. It fully works now but I will attempt moving it to the bottom of the body tag – Lairinus Oct 22 '15 at 16:37