Just figured it out! I'm new to Jade and didn't know that the head was taken care of by the layout.jade file. Once I placed the script references in the layout.jade file under the head where they belong, everything worked fine. Thanks for your help and suggestions everyone!
Trying to run or include javascript in the head of page using Jade
-
09-07-2023 - |
سؤال
So, this it my code:
extends layout
doctype html
html(lang="en")
head
meta(charset="UTF-8")
title = My Page Title
script(type="text/javascript",src="../javascripts/jquery-git2.js")
script(type="text/javascript").
console.log("this should work, right?")
body
block content
h1= title
div !{article}
Strangely enough, the scripts run and include just fine when I put them in the body, but I want them in the header. Am I missing something? Thanks in advance! I'm totally stuck on this one.
المحلول 2
نصائح أخرى
Your template generates nested <script>
tags.
Try unindenting the second script
:
script(type="text/javascript",src="../javascripts/jquery-git2.js")
script(type="text/javascript").
console.log("this should work, right?")
لا تنتمي إلى StackOverflow