Resilient Web Tips

Whether you use a computer, phone, table or some other device to access the Internet, you expect it to work. Sometimes things can break. Your connection is slow. Images don’t load. They are using a third-party tool that is having their own issues with the Internet. What can you do? Wait. Try again. Come back later to see if they fixed it.

Resilient Web Tips
Image by 3D Animation Production Company from Pixabay

The Internet provides information to users. By allowing them to use, whatever tools they wish. This feature makes the web resilient or fault tolerant.

What is a resilient website?

Being fault tolerant or resilient is part of the how the web works. HTML and CSS are the simplest tools for building a website. If errors are in either the HTML or CSS, the browser skips the errors and loads the page anyway. It may not look the way you want, but people can read the information.

Other programming tools like JavaScript don’t have built in fault or error tolerance. To make your code more resilient, you have to handle errors and missing information.

What can you do?

1. Start with the basics

Use HTML and CSS. HTML is the foundation of the web. You can build a website with HTML only and have it work. CSS allows you to use new features and older browsers ignore what they don’t understand. The more things we add to our web apps, the more they affect user experience. site performance and accessibility.

2. Pick the right framework for the job

JavaScript can enhance the user experience. It can also slow the site performance down. JavaScript Frameworks allow you to build things that you can’t using HTML and CSS. Before you decide to use a framework, you need to ask if you really need it. Or can you use Vanilla JavaScript instead? Consider adding less to your next project.

3. Prevent errors and make them easy to fix

Lot of things can break on the web. Your network connection fails. You clicked on the wrong thing. Or something else breaks behind the scenes. Web developers can build their web apps to prevent errors and make them easy for the user to fix. When you use JavaScript, you need strategies for making a resilient UI. Callum Hart shows you how to build a resilient JavaScript UI.

Where can I learn more about making resilient websites?

Jeremy Keith wrote Resilient Web Design. A book that gives you ideas and approaches on how to build a more resilient web.

Getting Started with JavaScript Accessibility

Accessibility means making your content as available to as many people as possible. You don’t know who visits your content. What browsers they use or how fast their internet connection is. You can build an accessible website with JavaScript You need to keep these considerations in mind.

Getting Started with JavaScript Accessibility
Image by Daniel Agrelo from Pixabay

JavaScript can be necessary

Sometimes, a no JavaScript solution may work. Other times, you may find that JavaScript helps to improve accessibility. It depends on what you want to do. Sara Soueidan wrote about her experience with building a tooltip without JavaScript. She found that it was harder than she thought.

Many people use a keyboard to surf the web. To navigate by keyboard, you jump from one focusable element to the next. You can start by using the tab key to move from one element to the next.

Which elements are focusable? HTML has interactive elements with built in focusability. Elements like text fields, buttons and select lists. You can navigate them by keyboard automatically.

Sometimes, we use HTML elements like <p>, <h2> or <div> to create custom interactive components. If you don’t make these elements focusable, this creates problems for keyboard users. The tab index attribute solves this problem by making a non-focusable element focusable.

Use the right amount of JavaScript

The problem starts when you rely on too much JavaScript. HTML and CSS can do a lot of things that you used to need JavaScript for. Now, you can use HTML to build your content and supplement with JavaScript.

Use the <button> tag to create buttons. You can use <div> or <span> tags to recreate the functionality of a button. When you choose to do this, you have to write extra code to mimic the behavior of a button. It is easier to use the button tag when you need a button.

Want to know more?

Use the Accessibility Developer Guide for best practices on creating accessible websites. Or JavaScript Accessibility Best Practices.

Image by Daniel Agrelo from Pixabay

Getting Started With Web Components

Everyone has their favorite tools, languages and JavaScript frameworks. JavaScript frameworks allow you to create components. Which you can reuse throughout your apps. What if you can’t use a specific framework? You can use Vanilla JavaScript to build web components.

Geting Started With Web Components
Photo by Pixabay from Pexels

What are web components?

Web components are a set of web technologies that allow you to create custom reusable HTML elements. These elements are not dependent on using a specific framework. You can use them without having to load a framework like React or Angular.

To build a web component, you can use these three technologies:

  • Custom Elements: A JavaScript API that allows you to create custom elements which you can use like HTML tags.
  • Shadow DOM: The Shadow DOM API provides a way to attach a hidden and separate Document Object Model to a web component. This keeps your component’s HTML, CSS and JavaScript separate from the rest of the web page.
  • HTML Templates: Use HTML tags <template> and <slot> to hold HTML that doesn’t display when the page loads. You load it with JavaScript at a later time.

Can I use web components in a JavaScript framework?

Yes. You can use your component in whatever JavaScript framework you want or none at all. If you need to switch to a new framework, you don’t have to rewrite your web component. Learn how to get started with building a web components.

Want to create your own components?

Check out these tools and resources for building your own web components.

Want to learn more?

You can learn more from the Web Components Community and Web Components.

Why Use a Coding Style Guide

What is a coding style? It is the way your code looks. The way you learned how to code, the tools and languages that influenced your personal style. Your style is influence by the many decisions that you make while writing code. If you work on a team, the team has its own standards that also influence how you write code.

Why Use a Coding Style Guide
Lubos Houska from Pixabay

Code is the way you communicate with other developers. To make sure that your code is understandable to other, you need to focus on writing code that is consistent and readable.

How do you make your code understandable?

Consistency

Pick a way of writing and organizing your code. You’ll want to decide:

  • Tabs or spaces for indentation
  • A naming convention for variables and functions
  • How much white space you are going to use

If you have trouble deciding, look at coding style guides for suggestions.

Python Coding Style Guide

Readability

Code is written for both computers and people to read. You want your code to communicate what it does. Remember, you won’t always be the person maintaining your code. You want your code to be readable and maintainable by your future self or another developer.

What can you do to make your code readable?

  • Pick a coding style guide for the language that you are using and follow it. By following it, you can focus on writing the code not formatting it.
  • Use meaningful naming conventions and comments. Check out How to Comment Your Code like a Pro.
  • Format and layout your code with white space.
  • Use tools to help manage your code. Tools like JSHint, Prettier, or W3C Validator

Whether you are working alone or on a team, using a coding style guide can help you be more productive as a developer. Remember, you aren’t writing code for the computer but for yourself and others.

DevTools Tips and More

What are browser dev tools?
Your web browser has a suite of developer tools. You can use these tools to analyze problems, edit CSS and debug issues with JavaScript.

DevTools Tips and More

Debugging can be a slow and challenging. If you use Chrome to develop, you may find that you can’t use the same tool in another browser. This can be frustrating when solving problems.

Can I DevTools?

Can I DevTools is a website by Pankaj Parashar that is similar to Can I use? It shows and compares dev tools. You can quickly see if a browser supports the dev tool you need.

More DevTools Tips

DevTools has many useful features and shortcuts. It is hard to learn them all. Start with DevTools Debugging Tips and Shortcuts to learn some of the useful features for debugging in Chrome, Firefox, Edge and Safari.

If you want to know how to do something in DevTools, check out DevToolsTips. You’ll find tips on how to empty the cache and do a hard reset, copy and elements style and debug unwanted scrollbars.

Browser DevTools Docs

Each browser has its own set of developer tools.