This article explains how to embed JavaScript code in a Weebly website. There are hundreds of reasons on why someone would add a custom script to any website. One of those reasons is for example to add any additional feature that doesn’t exist per default on your chosen Weebly theme.
Embed Javascript code in Weebly
There are different ways on how we can add Javascript in Weebly. Mainly, three different ways to add scripts based on the need and usage.
- Linking an external script file – effective on site level
- Embedding within header and/or footer of a specific page – effective on page level
- Adding within the content of a page – effective on element level
Linking an External Script File
Some kind of functions need a script file to be linked at site level. This is when you’ll need to link an external script file.
You’ll need to attach the .js file in object via Weebly Site Editor following these steps: “Design > Edit HTML/CSS > Assets”.
Hit on the + icon then select “Upload File(s)” and attach the script file.
Once file is uploaded, you’ll need to link the file at a website level always via the weebly Site Editor and following these steps: “Settings > SEO > Footer Code” section using the below code:
Embedding within header and/or footer of a specific page
The previous explained method allows us to embed Javascript at website level which is useful for certain features. However, if we’re taking a feature that requires to embed a code to a particular page, say for example a tracking code for a product page, will definitely need to add the code to a page level.
In order to add Javascript at a page level, you’ll need to paste the following lines of code under “Pages > Select a page > Advanced Settings > Footer Code”.
Adding Javascript Within the Content of a Page
In order to embed a script at an element level, you have to use “Embed Code” element to paste the script along with the HTML / CSS code.
We hope this article helped you learn how to embed Javascript in Weebly. You may also want to see our guide on how to add HTML code to Weebly.
If you liked this tutorial, then you may consider subscribing to our WeeblyTutorials YouTube Channel for Weebly video tutorials. You can also find us on Twitter and Facebook.
Hello,
Shouldn’t here be some code after this,
“Once file is uploaded, you’ll need to link the file at a website level always via the weebly Site Editor and following these steps: “Settings > SEO > Footer Code” section using the below code:
”
There is no code following
How do I actually provide the javascript file (.js) into the html code? You need to provide a source for where it is stored, based on my very limited understanding. This doesn’t tell me how to do that. I have the script on my computer.