Hello, I'm new to web dev but have been programming for a long time now. I'm trying to reference an external JS file in my HTML <head> to make a simple webapp calculator. I'm done with the design but would like to have an external file to handle my functions (just to make it neater). My file has two functions, one to evaluate the mathematical expression from a string: Evaluate(expression) and one that forms the expression based on buttons clicked: AllBtns(id). Now my problem: According to this StackOverflow answer, I need to include my file in the HTML <head> before I use the functions, which makes sense to me. However <head> is locked in BSS, can I load my function further into the HTML, such as in <body>? Is there a way to get around this without exporting my design? If there isn't, I would urge the devs to allow us to at least add a script attribute to <head>.
<head>is locked in BSS
You can find in the forums lots of examples on how to include external JS and you can start learning from those. Usually, external .js are referenced at the end of the HTML file, but if you really what to add something into the head, and you're using the latest BSS 4.3.1 there's a specific function in the settings menu.
Thanks for the reply marrco, if I may trouble you with a few more questions.
- Is there an advantage to including the script at the end of the HTML file rather than in the <head>?
- Where exactly at the end of the HTML should I load the JS script (Screenshot included if relevant)?
Lastly, I can't seem to find a question on the forums which addresses my issue, could you please link one? Thanks in advance
Is there an advantage to including the script at the end of the HTML file rather than in the
speed and following standards
Where exactly at the end of the HTML should I load the JS script (Screenshot included if relevant)?
Lastly, I can’t seem to find a question on the forums which addresses my issue, could you please link one? Thanks in advance
These forums are specific for BSS, that's just a tool. Not general help for HTML/CSS website building. But I'm sure you'll try many posts discussing how to link and use external JS libraries
Thanks a lot, due to your help I was able to make the webapp...well almost, one function left. Here is the app, if you're curious or have any comments.
good job @notanon.Your calc works fine.
Just one comment based on my personal taste: on ≥576px devices, it probably looks better inside a smaller centered flexbox