Creating a simple weather app with Open Weather API

How do you get the weather? You could use an app or create your own. First, you need a way to get weather data. You can use an Application Programming Interface to get the data that you need.

Creating a simple weather app with Open Weather API

Where can you find APIs to use in your projects? Try ProgrammableWeb. It is an API directory that lets you find the right API for your project. I found a weather API called Open Weather. Open Weather allows you to get the current weather data, hourly or daily forecast and more.

With Open Weather, I created a simple weather app. It gets the current temperature, daily forecast (highs and lows) and weather conditions. Then, it tells you if the weather was right for riding a bike.

Getting Started

Before writing any code, I looked at Open Weather’s documentation. It explains how to use their API. They include examples using different programming languages like JavaScript. These examples are helpful were helpful to learn what I could do with the API.

On their examples’ page, I found Weather.js. Weather.js fetches data from Open Weather for you. It makes it easy to get weather information from Open Weather.

Building the App

Before building the app, I researched other weather apps to get an idea of what I wanted mine to look like. Then, I sketched out an idea on paper.

I chose to use HTML, CSS and JavaScript. Since I am familiar with Bootstrap, I used it as well. I built my prototype with Bootstrap’s starter template. Then, I wrote my own JavaScript file to fetch data from Open Weather using Weather.js.

Open Weather has weather icons. Weather.js doesn’t use those icons. I looked at the JavaScript and wrote code to get the icons.

Weather.Current.prototype.icon = function () {

Now, my app shows the current and forecast temperatures, weather icon and conditions.

Bike Weather App Screenshot

What to do differently

Open Weather returns weather information for a specific location. Instead of hardcoding the location, I would use the location of the browser. Right now, I used Bootstrap for the UI. I would use a different tool for handling layout like FlexBox or CSS Grid.

Why use HTML and CSS over JavaScript?

When you build for the web, you have to make many different choices. What am I going to build? What tools are I going to use? The number of tools, frameworks and libraries available can be overwhelming.

Why use HTML and CSS Over JavaScript
Photo by Nicole De Khors from Burst

JavaScript is no exception. You have a wide variety of JavaScript frameworks or libraries to choice from. Should you use these technologies for every project? HTML and CSS can now do many things that you once needed JavaScript to do.

What is the Lean Web?

The Lean Web is a set of simple web development principles. Best practices for building the web with HTML, CSS and JavaScript. Chris Ferdinandi who wrote the Lean Web encourages you to embrace the web as a platform. To let the browser to do what it does best.

Chris gave a talk on Lean Web at WordCamp LA 2020.

The Three Lean Web Principles

Principle 1. Embrace the Platform
Use HTML over JS, CSS over JS and use the browser for what it is good at. Does that mean you shouldn’t use new tools and technologies? No. You need to decide when you should use them and why.

Principle 2. Small & Modular
Look for small, focused tools that do one thing really well. Use APIs, native browser methods or alternative tools lie Svelte or Preact. Use utility-first CSS to prevent redundancy in your stylesheets.

Principle 3. The Web is for Everyone
Not all browsers support native features. You can use a polyfill to replicate the feature. As developers, we make choices that can break the web for some people. Chris suggest using the A11Y Project to make sure that everyone who wants to use your web applications can.


You don’t want to avoid using new tools, frameworks and techniques in favor of old ways of doing things. When you are building any project, you have to make choices on what to use. Sometimes, HTML and CSS is the better choice.

Write Better Documentation for Your Code

Do you write documentation? Most developers love to write code. They write code that solves problems. It helps people to get something done. If they write documentation, it is quickly written. A task to be completed so you can get back to writing code.

Write Better Documentation For Your Code
Image by Christine Sponchia from Pixabay

How do you choose a new framework? You look at the features to see if it does what you want. Then, you read the documentation. If it is hard to read or non-existent, you’ll get frustrated and choose a different solution.

If you want people to use your code, you need to write great content.

How do you write better documentation?

  • Decide who you are writing it for
  • Decide what you are going to include
  • Make it easy to use
  • Keep it up to date
  • Read great documentation

Decide who you are writing for

You need to know your audience. Are they developers, clients or customers? Developers want to know how to use your code. Or what can they do with it. Your clients may want step by step instructions on how to use it.

What are you going to include

Decide on what you want them to know. Create a list of questions or items that you need to cover. A technical audience may want to read tutorials, how-to-guides and/or references. Beginners learn better with simple step by step instructions. For everyone, you may want to include videos as well.

Make it easy to use

No matter what you are writing, decide how you are going to organize it. If you are writing a tutorial, you may want to start by explaining what you are planning to talk about. Use formatting styles like headings, bulleted or numbered lists and bold or italics. Formatting styles help guide the reader through your documents.

Keep it up to date

Developers make improvements and changes to their code. When they do, the documentation needs to change as well. Plan time to update it. Apps and other projects fail because the content isn’t kept up to date.

Read great documentation

You can learn how to write better by reading. These style guides show you how to write great developer content.

More Resources

How do you reduce website bloat?

Why is my website slow? It is a common question developers, designers, bloggers and even your visitors ask. No website is immune from having speed issues.

How Do You Reduce Website Bloat
Photo by Farzad Nazifi on Unsplash

What causes website bloat?

How you designed and built the site affects its speed. Things like images, videos, CSS and code can impact your site. Even your server can affect how the site performs.

What can you do to speed up your site?

1. Optimize your images

You may be using images created in file formats that aren’t designed for the web. They may be large in file size as well. You can use an optimize tool to shrink the file size down without noticeable loss in quality. When you optimize an image, it loads faster on your site.

2. Get rid of unnecessary images

Check your web server for unused images. Unused images can affect user experience and performance of your site. If you aren’t using these images, delete them off your server. WordPress users can clean up their images using plugins or manually. If you have Windows, you can use Powershell to find and remove used images.

3. Optimize your videos and other files

Large files can slow a web site down. Files like videos or PDFs get quite large. You can optimize them before uploading. For PDFS, you can use Adobe Acrobot Pro’s PDF Optimizer to make them faster for the web. With videos, you can use a video hosting service like Vimeo or YouTube to host your videos. Then, you can embed them on your page.

4. Optimize your CSS

CSS files can get large and unruly after a while. Optimizing and managing them can be a challenge. It can be hard to find unused styles. You can use a tool like Helium CSS to find them. By getting rid of unused styles, you can reduce the size of your CSS.
Some of your styles are used more often than others. Print styles are used when a page is printed. You may want to separate them into their own file. With frequently used CSS, you may want to consider using inline styles instead. Before uploading your CSS, you can use a minifier to reduce the amount of whitespace it uses.

5. Check your code for speed issues

Are you using old code? If you are, you may need to rewrite, refactor or even replace it. Look at older code and decide if you need to keep it. If not, remove it.

6. Review the content of your page.

You may have too many items on your page. Do you have old or outdated content? If so, you can remove them. Review the rest of the items on the page to see if you can remove some content and still achieve the same goals of the page.


Preventing website bloat can be a full time job. By changing your development process to include optimization. You can prevent it from getting slow.

Getting Started with CSS Variables

What are CSS Variables?

Most programming languages allow you to use variables. Variables are used to store information and manipulated by the program. In CSS, you previously need a preprocessor like SASS or LESS to use variables. CSS Variables are custom properties that you define with specific values and reuse throughout your CSS document.

Getting Started with CSS Variables
Photo by Pexels from Pixabay

In CSS as well as programming languages, you can declare your variables either globally or locally. A global variable is a custom property that is available to your entire HTML document. To declare a global custom property, you use the :root pseudo-class.

For example, you want to define your theme colors. You can use the :root pseudo-class to do that.

:root {
    --main-color: blue;
    --main-text-color: aqua;

You can also declare a variable locally. By declaring a custom property locally, you limit the scope or impact that the variable can have.

.primary-background-color {
    --background-color: teal;

When you create a CSS Variable, you can overwrite the value. By taking advantage of cascade, you can create a new style that changes the default value of a global declare variable.

.text-color {
    --main-text-color: orange;


Preprocessors allow you to use a variable by referencing its name. You use the Var() function when inserting the value of a custom property.

.featured-content-box {
    background-color: var(--main-color)


Sometimes you need to do a little math to get your styles to work they way you want them to. Calc() is a native CSS way to do simple math calculations. With it, you can do addition, subtraction, multiplication and division. CSS Tricks talks about use cases for Calc().

For example, you may want to change the width of a style.

.box {
    width: calc(100% - 80px);

Why use?

CSS Variables can be overwritten, cascade down and used in JavaScript. If you don’t want to use a preprocessor like SASS or LESS, you can use custom variables to make managing your styles a lot simpler.

In Web Dev Simplified’s CSS Variables Tutorial, he gives you a quick introduction on how to use them. You learn what they are, how to write them and use them with JavaScript.


At first, CSS Variables sounds complicated. They can help you to make your CSS easier to maintain. Variables are a lot easier to use than hex or hsl codes.