top of page
Filter by Category

3:03

6331

Wix for Developers

How to Start Coding on Wix Studio

How to Start Coding on Wix Studio


Hello everyone! Today, we're jumping into the exciting world of web development on Wix Studio. If you're eager to get your hands dirty with code, you've landed at the right spot. This introductory guide will take you through setting up your dev environment on Wix Studio and writing your very first line of code. So, buckle up and get ready for a ride into the world of coding!


Getting Started with Wix Studio


Before we dive in, let's get familiar with the development environment. To activate the dev environment in Wix Studio, click on the curly braces icon, then hit "Start Coding". This sets up your dev environment, paving the way for some coding action.


Once you're in, you'll notice that your page code is divided into different sections:


- Page Code: This contains the front-end code specific to each page.


- Master Page: This is like your universal remote control. Any code here will run across all pages on your site—super handy for site-wide features.


- CSS and JavaScript: You can add both public and backend JavaScript files here as well as custom CSS extensions.


But we're just scratching the surface. You can also search your codebase, tap into CMS collections, import npm and V code packages, as well as custom apps. Plus, you can sync with GitHub and work locally. Talk about a full toolkit!


Exploring the In-Editor IDE


Now that we've got the initial setup down, it's time to explore the in-editor IDE (Integrated Development Environment). You’ll notice this friendly little tab that tells you which file you're working on. Right now, we're in the homepage file.


You'll see an API documentation reference followed by the `$w.onReady` function. This function is a staple of every page—where most of your front-end magic will happen. It signals that your page is fully loaded and ready for action.


Say Hello to the Property and Events Panel


To your right, you'll spot a panel dedicated to properties and events. When you click on an element in the visual editor, this panel gives you all the juicy details: element ID, default visibility, event handlers, and CSS classes. It’s like having a backstage pass to your site’s elements.


Above this panel, you'll find a button to connect to the VS Code-based IDE, a run button to preview your code, a code formatter, and options to maximize and minimize the IDE. You're fully equipped!


Let's Write Some Code!


Ready to write some code? Let’s get our hands dirty. If you haven't already, add a button and a text element to the page. Give them some default text. Our mission is to create a click handler for the button to modify the text in our text element.


Inside your `$w.onReady` function, type `$w` and the ID of your button within parentheses. This targets the element you're scripting for the click handler.


Pro Tip: IDs matter! When you add elements to your canvas, they come with default IDs. Best practice? Give them meaningful, easy-to-remember IDs.


With your new IDs in place, let's create a click event for the button. In the click event body, add a console.log statement for some testing flair. Then, type `$w` again to explore the list of available IDs—you’ll find the text element ID there.


Testing and Deploying


Time to see the magic! Click "Run" to test your code in preview mode. There's a nifty developer console at the bottom that displays your logs and error messages. Check everything here to ensure it behaves as expected before deployment.


As you click around, watch your text update and logs pop up in the console. It’s alive!


Deploying your code to the production environment in Wix Studio is as simple as clicking the "Publish" button. Once you’ve hit publish, your changes are live!


Wrapping Up


And there you have it—your first dive into coding with Wix Studio. This is only the starting line of your developmental journey, and we're thrilled to have you along for the ride. With the basics under your belt, the creative world of web development is wide open to you.


---


At NewForm, we’re passionate about helping you hone your design skills and connect with industry leaders. We offer monthly web design challenges with attractive cash prizes, weekly skill-building events, and exclusive monthly sessions featuring top web design professionals. Here, you get to learn from the best, access invaluable resources, and build captivating web projects.


So, if you’re ready to elevate your design prowess and join a vibrant community of creatives, this is your moment! After diving into today’s post, head over to NewForm and seize more amazing opportunities. Let's build the web, one stunning site at a time!

bottom of page