1

I am trying to add custom javascript into my website for a widget on wordpress using the wpcode plugin but I keep getting an unexpected token error. There is a already created that isn't accessible in the text box where you add the code. Here is the line of javascript:

<script src="https://apis.owenscorning.com/client/widget.js" async></script>

I've tried deleting the opening and leaving the "src=" in hopes of it accepting the script that is inaccessible but the unexpected token error doesn't go away.

6
  • Here is the line of javascript: - that's HTML - anyway, there is no error when loading that script - what makes you think that script is the source of the error? Did you put that HTML in the middle of javascript? Commented Mar 7, 2024 at 4:08
  • Here is the link to what I am trying to add: owenscorning.com/en-us/roofing/widgets/shingle-widget @JaromandaX It says its javascript. If not I can add it as html and see if that works. Thank you Commented Mar 7, 2024 at 4:18
  • huh? what do you mean add it as html? I think you're confused Commented Mar 7, 2024 at 4:30
  • Yes, I was very confused. I did figure it out. Your solution worked. I really appreciate you answering the question. You are the real MVP @JaromandaX Commented Mar 7, 2024 at 4:39
  • I didn't supply a solution though, I suggested you that you may have put the tag in the middle of some javascript - is that what you fixed? Commented Mar 7, 2024 at 4:41

1 Answer 1

2

Yes that's the script tag which you would normally place in the <head> tag of your html file. However, that script of you paste that url into the browser you'll see its a self executing widget code. Since that code looks for the head tag on the document etc. I would like to recommend you place that script of code right at the bottom of your <body> closing tag:

E.g.

<body>
 ....[other code here]....
  <script src="https://apis.owenscorning.com/client/widget.js"></script>
</body>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.