How to Embed Javascript Code in Weebly

/, Tutorials/How to Embed Javascript Code in Weebly

How to Embed Javascript Code in Weebly

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 can upload the needed .js file under “Design > Edit HTML/CSS > Assets”. Click on the + icon then choose “Upload File(s)…” and upload the script file.

Add Javascript in Weebly

Once file is uploaded, the next step is to link the file at site level under “Settings > SEO > Footer Code” section using the below code:

<script type=”text/javascript” src=”http://yoursitename.weebly.com/files/theme/file-name.js”></script>

Embedding within header and/or footer of a specific page

The previous explained method allows us to embed Javascript at site level which is suitable 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 need to paste the code under “Pages > Select a page > Advanced Settings > Footer Code”. Any scripts used in footer / header section at page level settings will be part of only that page of your site.

Adding 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.

By | 2017-12-21T13:19:20+00:00 December 21st, 2017|Beginners Guide, Tutorials|0 Comments

About the Author:

Editorial Staff at WeeblyTutorials is a team of Weebly experts.

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.