add-javascript-to-wix

How to add JavaScript to customize your Wix site with Velo

03/09/2021

Want to do more with your Wix site? Whether you’re a creative professional, business owner, or building something just for fun, you can add tons of advanced features to your site with a bit of JavaScript know-how.

Learning JavaScript can seem daunting — especially if you’re new to coding. But it doesn’t have to be that way. Once you know some JavaScript basics, you’ll be able to create one-of-a-kind features for your site.

In this article, we’ll look at how you can get started adding JavaScript to your Wix site.

We’ll also share a few tips for learning JavaScript from Kenny, the Curriculum Developer behind our free Create a Professional Website with Velo by Wix course. For this course, we partnered with Wix to guide you through all the steps for adding JavaScript to your Wix site — no coding experience needed.

How do I add JavaScript to my Wix site?

The way to add JavaScript to your Wix site is using Velo — Wix’s full-stack development platform. Velo can be accessed from your Wix site editor (under Dev Mode).

Once Velo is enabled, you can add JavaScript code that makes your drag-and-drop page elements more interactive, whether that’s adding event listeners or displaying content pulled from a database.

“Velo is great for anyone who wants to tweak or add more to their drag-and-drop site. You can take Velo and write some JavaScript code to include customized interactivity and even to create a full stack experience for your visitors,” Kenny says.

How much JavaScript code do I need to know?

To make the most out of Velo, you’ll need to have a basic understanding of JavaScript.  A good place to start is by learning about if statements, for loops, variables, data types, collection types, arrays, and objects.

You’ll also need to learn a bit of Velo’s own syntax. The Velo syntax helps simplify the coding experience. Once you’re familiar with the syntax, you’ll be able to link custom code to your site’s images, text, and forms, interact with databases, and access back-end files.

With a basic understanding of JavaScript and Velo syntax, you’ll be able to add one-of-a-kind features to your site. Our Wix course takes you through all of these basics.

What can I do with JavaScript on my Wix site?

JavaScript can enable you to add interactivity to your Wix site, pull and display information stored in databases, and more. For example, when someone selects a button, you can program a pop-up that says “Hello world!” Or when someone comes to your site for travel ideas, you can generate a unique list of travel destinations each time, pulling from a database that you created.

In this section we’ll show you a few things that you’ll learn how to do with JavaScript and Velo in our free course.

You’ll learn to code interactive page elements, like this fun color scheme generator.

You’ll find out how to populate your site with data from third-party APIs, including up-to-date weather information.

And you’ll learn how to retrieve and display data — like statistics that show how your online business is doing — from a database that you’ve created.

“Traditionally, if you wanted to set up a database, you would need to find a database engine and install SQL onto your computer. But with Velo, all of this comes with the platform already,” says Kenny. “You’ll need to enable a few settings and give a name to your database, and then you can directly interact with it through the Velo interface.”

Tips on adding JavaScript code to your Wix site

Here are a few tips from Kenny on getting started with JavaScript for your Wix site.

1. Check the drag-and-drop capabilities first

Before you do any coding, see if what you want to make already exists as a drag-and-drop element. “Wix offers a lot right off the bat. They put a very thoughtful effort into what users might want on their sites. And often, the functionality is already set up for you,” says Kenny.

2. Experiment and try things out

You can always undo changes, so experiment and try things out, Kenny shares. “You can see how the site looks to your users using the Preview button. So after you write your code, you can try it out and see if it actually works and if it’s something you want. You’ll also see a console in Preview mode that tells you if there are any errors so you can fix them. Until you Publish your site, users won’t see your changes, so play around!”

3. Get unstuck with the Velo documentation and Wix Forum discussions

When you get stuck on something, you can search for solutions in Wix’s Velo documentation. “Often, if you look through the documentation for something really specific, you’ll find it. And you’ll find code examples of how to implement it,” Kenny says.

You can also ask for help in the Wix Forum Discussions. Wix has a dedicated community of people helping to answer questions, and staff members who check in regularly to provide solutions.

Getting started

Ready to do more with your Wix site? Head over to our Create a Professional Website with Velo by Wix course to get started.

We can’t wait to see what you build!

Related articles

7 articles