1

Why does the page load faster when we put lines like this:

script(src="/Scripts/jquery.timeago.js")

at end of our tag and not in the

Say :

//Jade file with JQuery
!!! 5
html(lang="en")
  head
    title Holamundo!
    script(type='text/javascript', src='http://code.jquery.com/jquery-1.9.1.js')
  body
    h1#headTitle Hello, World
    p#content This is an example of Jade.
    script
      $('#headTitle').click(function() {
        $(this).hide();
      });
      $('#content').click(function() {
        $(this).hide();
   });
Sébastien
  • 11,860
  • 11
  • 58
  • 78

1 Answers1

3

The Pug template will be transformed into HTML, which will be sent to the browser.

The HTML output will be interpreted by the browser in the same way regardless of how it has been generated (by hand, via a pug template or other system).

Therefore your question is ultimately this one: Where should I put <script> tags in HTML markup?

Further reading: How exactly does <script defer="defer"> work?

Sébastien
  • 11,860
  • 11
  • 58
  • 78