Announcement

Collapse
No announcement yet.

Javascript - where to put it

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript - where to put it

    I placed a javascript in my custom global header. Would it be better to add the script to one of the js files instead of the header on each page. If so, which one? Thanks in advance

  • #2
    It depends on what type of script are you adding to the site, usually we're talking about tracking codes or conversion codes.

    For tracking codes the best is to place them on the Global Footer, SETTINGS > DESIGN > HEADER AND FOOTER.

    The Conversion codes can be added on the checkout 4, SETTINGS > DESIGN > TITLES AND CONTENT > CHECKOUT 4.

    This scripts make reference to external site, so you want them to be secure; always check that they are https instead of http. They also like to include links to their website so it's better to place them at the footer instead of the header.

    Using .js files is good when you're adding some custom javascript that you wrote and you want to keep it behind the page, it's accessible anyway. And for the search engines it doesn't makes a big difference as long as you have the SCRIPT tags around it.

    It's more organized to have .js files and it makes the code reusable, you can just save the file your template folder and then make the reference directly on the html.

    Comment

    Working...
    X