What’s the difference between hosting providers? For example, what is the difference between GoDaddy and Hostgator, which seems like “traditional” web hosting providers, to others like Heroku, Digital Ocean, AWS, and Firebase?
When would I use one over the other?
They were hoping for detailed thoughts, so I’m going to oblige!
To be honest, I’m already confused. (Sorry, I promise I’ll try to be more helpful as we go on.) Why is WordPress hosting one dollar more expensive than the Web Hosting plan? If you buy the $5.99 Web Hosting plan are you prevented from installing WordPress on it? Or is it just convenient in that if you pick the WordPress hosting it comes pre-installed and configured? WooCommerce is just a plugin for WordPress, so are you prevented from installing that on the WordPress hosting plan until you upgrade to the WordPress Ecommerce Hosting plan? (To be fair, WordPress.com unlocks WooCommerce at the highest plan as well, so it’s trod territory.) Why is the VPS Hosting plan the cheapest? I don’t blame you if you also find this as confusing as I do, especially as this is just one of many different charts of hosting options they offer.
GoDaddy makes a billion zillion dollars a year, so I’m sure they’ve got this stuff figured out, but I’ll tell ya, after a couple of decades of web development experience, I’d be totally guessing at choosing a plan from options like this. Cynically, it feels like confusion might be a sales tactic.
Technology
I do know this: these plans are for PHP / MySQL sites. That means WordPress, Craft, Perch, Ghost, Drupal, Joomla, etc. This is the LAMP stack which has all the big CMSs covered. Just the way it is. This is going to be the case at Media Temple, Hostgator, Bluehost, and lots of hosts like that. I think a “traditional” web host, as you put it, isn’t a bad way to think about it.
Do you wanna run PostgreSQL or MariaDB instead of MySQL? Or you wanna run ASP instead of PHP? I’ll bet you all these hosts have some kind of answer for those things. The answer is going to be something like “Don’t use our shared hosting product, use our raw VPS (‘Virtual Private Server’) product which has direct root access, and you can install it yourself.” I guess that’s fine, but just know those things aren’t first-class citizens of their hosting. If you have trouble, I’d worry you’ll have a hard time getting good support.
Which leads me to my point: you should go with the happy path offerings from hosting providers.
Say I want to write a Python app. I’m not going to buy a Hostgator server. I’m sure you can get it to work, but it’s not something they really promote. It doesn’t feel like it’s on a happy path. Whereas if I look around at Heroku, they make it a first-class citizen of what they offer:
I can’t vouch for it directly as I’ve never used Heroku, but I’ve heard lots of good things and they’ve been doing this for a good 15 years.
Happy paths are about friendly pairings
Heroku reminds me of another divide in hosting providers that I think is significant. Those “traditional” web hosts don’t lift a finger to help you get your websites over to them. It’s more like: here’s your FTP credentials, good luck. With a host like Heroku, they are giving you a CLI to like heroku container:push to deploy your local code to production. Better, it will deploy right from your GitHub repository. Why every single web host in the world doesn’t help with that is a mystery to me. A web host that helps you with deployment is a valuable thing.
We were talking about happy paths, right? Heroku calls themselves a “Cloud Application Platform.” The happy path there is those server-y languages. Node, Ruby, Python, Go. What if you don’t need any of that? Say you’re building a static site, using a static site generator (like Eleventy) at the core (Jamstack, as it were). Do you pick Heroku? Probably not. While surely you could pull it off on Heroku, static site hosting isn’t core to Heroku, and so not a happy path.
Where should you host a static site? That’s Netlify’s whole ball game. Netlify is a super happy path for static sites.
In fact, Netlify nailed the Jamstack-style hosting thing so strongly that lots of companies have been trying to provide similar offerings. I think of Azure’s Static Web Apps as an example. So why use Azure over Netlify? If it feels like a happy path, and it might if you’re using other Azure products, assuming their products play well together. Azure is a massive cloud platform with loads of other offerings. Or you might just have more experience and developer muscle memory for Microsoft products. We’ll get to that later.
Jamstack (essentially meaning static hosting + services) is available in lots of places now. Cloudflare has Cloudflare Pages, which you might take advantage of because of the unlimited promises (unlimited sites, unlimited requests, unlimited bandwidth, and even unlimited team seats).
You might choose Cloudflare Pages because your Cloudflare products like access or workers that are important to you and it feels like the happy path to keep it all together.
Vercel has Jamstack hosting, but they’ll run servers for you if you need them. Their popular framework, Next.js, prebuilds pages, but can also deliver server-side rendered pages with a Node back end. Vercel gives you that back end.
Next.js on Vercel is a very happy path. “Deploy on the platform made for Next.js,” they say. Hard to beat that.
AWS Amplify is ultimately Jamstack hosting, and the happy path there is using Amplify to stitch together other AWS services. That’s literally the point of AWS Amplify.
Need auth? It’s Amazon Cognito under the hood, but Amplify helps you stitch it into what you are doing. Need storage? S3 is an industry standard, and Amplify helps you integrate it. Need a database? Amplify helps you model it and build APIs.
Firebase has Jamstack-style hosting, and the happy path is leaning into the Firebase framework.
Firebase has lots of very useful features, like real-time data storage, authentication, and RUM analytics. If I wasn’t using any of those things, I’m not sure I’d pick Firebase hosting. Like for a basic Jekyll blog, can it be done? Absolutely. Would I personally do it? Probably not. It’s not really leaning into the Firebase offerings, making it way less of a happy path.
It’s worth talking about ? developer “muscle memory” for a moment. You build muscle memory for the things you do a lot. If you’ve got five sites on Netlify already, and you’ve gone through those motions over and over, it makes sense that your sixth site is on Netlify as well — even if some other host might be a slightly better fit. Knowing your tools well and feeling comfortable is a big deal. You can compare pricing and features and all the bits and bobs, but muscle memory is one of the most powerful choice influences, and I think that’s perfectly fine.
Your host should take care of your core needs
Remember how I mentioned a web host that helps you with deployment is a valuable thing? All of these hosts do that: Netlify, Vercel, AWS Amplify, Google Firebase, Cloudflare Pages, Azure Static Sites. That’s become table-stakes for hosting providers. There are more table-stakes as well.
The table stakes of modern web hosts.
Beyond, ya know, hosting the website.
HTTPS. The host should give my site an SSL certificate. Probably automatically, and probably for free (since Let’s Encrypt is free).
CDN. The host should help serve as much as my site as is practical from a CDN, even if it’s a paid feature or requires configuration.
Deployment. The host should connect to Git repositories and move files from the main branch to the production site.
Staging. The host should provide staging environment(s).
I should circle back to the WordPress (and other PHP/MySQL CMS) thing. That’s what this site is. Traditional hosts serve this market. WordPress is 35.2% of all websites, which is bananas, and means there are wheelbarrows full of money in that hosting market. But in my experience, the traditional hosts do almost none of what I just called table stakes in hosting. A lot of times, you’re on your own for HTTPS. You’re on your own for integrating a CDN. You’re on your own for deployment. Staging just means buy another server. It’s just a weird time for hosting right now, with such a wide gap in modern web hosts doing so much and traditional web hosts doing so little.
That’s not true of all WordPress-specific hosts though. Using a WordPress-specific host for hosting WordPress is about as happy path as you can get. I’m on Flywheel now and appreciate all they do. They cover that entire list of table stakes, and go further still, helping with local development.
You asked about Digital Ocean specifically…
I feel the least qualified to explain Digital Ocean, but I think it’s fair to say that Digital Ocean has a lot of happy paths. They have this concept of a “Droplet” (it’s a server) which is spun up from “containers.” I wouldn’t worry terribly much about the idea of containers at this point, but suffice it to say, they are pre-configured servers that can run any sort of combination of technologies. If you want to fire up a LAMP stack thing in a Droplet, that’s a first-class citizen. But so are lots of other technologies. Consider Strapi, a CMS that is Node, Nginx, and PostgreSQL. Digital Ocean has a Droplet for that’s ready for it out of the box.
Droplets also start at $5/month, so they are just as economical as other hosts, if not more so. You might find hosting products that are actually Digital Ocean under the hood! For example, the WordPress hosting tool SpinupWP allows you to quickly create configured WordPress hosting environments, but it doesn’t do the hosting itself, you “bring your own” host, which is likely Digital Ocean or AWS (Amazon Web Services).
It only gets more complicated from here
If Digital Ocean seems complex, wait until you hear about AWS. We talked about AWS Amplify earlier, but that’s like AWS designed for individual developers like you and me to scaffold apps quickly. It’s very cool, but it’s a small wedge of what all that is AWS.
AWS is this massive cloud services provider, meaning that, sure, you can spin up web servers, but there are also hundreds of other services for things, like databases, storage, serverless stuff, APIs, logs, heck — you can rent a damn quantum computer there, which is like sci-fi stuff. It’s not that a normal developer can’t use AWS for a web host, it’s just like, not really designed with that kind of DX in mind. This guide on installing WordPress makes me sweat. AWS is super powerful, has solutions for everything, and is priced as low as it gets. Perhaps it’s useful to think of AWS as like down-to-the-metal web infrastructure, designed for large-scale operations. Web hosts might even be built on top of AWS, for example.
Matching your needs to what’s available
Let’s do some quick hits of needs matched to options. This is in no way comprehensive. I just slapped it together with things that popped to mind that feel happy path aligned.
It’s worth re-iterating that there is a lot of commonality in hosting. Say you’ve got an index.html file you want to host and that’s your entire website; literally any web host will do that. These are all web hosts, after all. They serve files and run code. They aren’t that different. We’re largely talking about DX here: do they run what I need to run? Is it straightforward? Do they help make it easy? Do they clearly offer support for it?
Is it the happy path?
Then there’s pricing
We haven’t really talked much about price. I know that’s a major consideration for a lot of people and I don’t want to downplay it. But it’s hard to talk about without knowing your needs. I also don’t want people to make major web hosting decisions based on something like a few dollars difference in monthly cost. If you spend half an hour troubleshooting you otherwise wouldn’t have had to, those savings are blown.
I find that web hosting is somewhat of a commodity market. The prices are fairly stable. If a host seems expensive, it’s probably because they offer a lot. If a host seems cheap, it’s probably because they cut costs in a way you’ll eventually feel. If you’ve got a little baby site, chances are, you’re going to be hosting it for free. And if and when the site grows up, the hosting costs will feel minimal and fair.
? Does all this seem kinda fun and exciting to you? If it does, you might think about a career in DevOps dealing with servers, deployment, infrastructure, and supporting developers doesn’t have to be a side-job to other development work, it can be a whole job.
When you think of installing analytics, you probably reach for Google Analytics. And you wouldn’t be alone. The platform’s tight integration with SEO and the implication that using Google products is beneficial to ranking means that Google Analytics is the most commonly installed analytics solution globally.
Google Analytics isn’t a bad choice: it’s free, it’s fairly comprehensive, and it does indeed tie most SEO efforts up with a nice bow.
But Google Analytics is also slow, extremely bad for privacy — both yours and your users’ — and for many people, it’s too unwieldy, having grown organically over the years into a relatively complex UI.
Some alternatives are fast, privacy-friendly, and geared towards different specialisms. Today we’re rounding up the best…
1. Heap
Heap is an event-based analytics platform. That means you can tell not just how many people visited your site but what actions they took when they were there. This isn’t a unique proposition, but Heap is one of the best implementations.
Heap offers an auto-track tool, which is ideal for new installations because you can get up and running immediately and fine-tune the details later. That makes it great for startups, although it’s also the choice of major corporations like Microsoft.
Heap’s free plan includes 60k sessions per year and 12 months of data history, but when you outgrow that, the business plans start at $12,000/year.
2 ChartMogul
ChartMogul is geared towards SaaS that offer subscription plans, staking a claim as the world’s first subscription data platform.
Services like Buffer and Webflow use ChartMogul to monitor their revenue and analyze the ROI of changes to their features, design, and user experience.
Ideally suited for startups, ChartMogul pricing is based on monthly recurring revenue; it has a free plan for up to $10,000 MMR; after that, pricing starts at $100/month.
3. Fathom
Fathom is an awesome, privacy-first analytics solution. It offers a simple dashboard and is ideal for anyone looking for simple analytics information to verify business decisions.
Fathom is ideally suited to freelancers, or entrepreneurs with multiple projects, as it allows you to run multiple domains from a single account. Fathom is entirely cookieless, meaning you can ditch that annoying cookie notice. It’s GDPR, ePrivacy, PECR, CCPA, and COPPA compliant.
There’s a seven-day free trial; after that, Fathom starts at $14/month.
4. FullStory
FullStory is designed to help you develop engaging online products with an emphasis on user experience.
FullStory is a set of tools, making it ideal for large in-house teams or in-house teams working with outside agencies or freelancers. It pitches itself as a single source of truth from which everyone from the marketing department to the database engineers can draw their insights, helping digital teams rapidly iterate by keeping everyone in the same loop.
FullStory uses AI to track and interpret unexpected events, from rage clicks to traffic spikes, and breaks those events down to a dollar-cost, so you can instantly see where your interventions will have the most impact.
There’s a free plan for up to 1k sessions per month; once you outgrow that, you need to talk to the sales team for a quote.
5. Amplitude
Amplitude has one of the most user-friendly dashboards on this list, with tons of power behind it. For project managers trying to make science-based decisions about future development, it’s a godsend.
The downside with Amplitude is that to make the most of its powerful data connections, you need to pump a lot of data in. For that reason, Amplitude is best suited to sites that already have a substantial volume of traffic — among those customers are Cisco and PayPal.
Amplitude provides a free plan, with its core analytics and up to 10m tracked actions per month. For premium plans, you have to contact their sales team for a quote.
6. Mixpanel
Mixpanel is a little bit more than an analytics program, aiming to be a whole suite of web tools it has ventured into split testing and notifications.
Mixpanel is laser-focused on maximizing your sales funnel. One look at the dashboard, and you can see that Mixpanel, while very well designed, has too many features to present them simply; Mixpanel is ideally suited to agencies and in-house development teams with time to invest — you probably want to keep the CEO away from this one.
Mixpanel has a generous free plan for up to 100k monthly users, with its business plans starting at $25/month.
7. Mode
Mode is a serious enterprise-level solution for product intelligence and decision making.
Ideally suited to in-house teams, Mode allows you to monitor financial flow and output the results in investor-friendly reports. You can monitor your entire tech stack and, of course, understand how users are interacting with your product. Wondering who handles the analytics for Shopify? That would be Mode.
Mode has a free plan aimed at individuals, but this tool’s scope is really beyond freelancers, and the free plan’s only likely to appeal to high-price consultants and tech trouble-shooters. For the full business plan, you need to contact Mode’s sales team for a quote.
8. Microanalytics
Microanalytics is a relatively new analytics program with a lightweight, privacy-focused approach.
Microanalytics provides a simple dashboard with acquisitions, user location, technology, and the all-important event tracking to monitor user behavior. Microanalytics is compliant with the web’s most stringent privacy laws, including GDPR, PECR, and CCPA. The tracking code is just 1kb in size, meaning that you’ll hardly notice its footprint in your stats.
Microanalytics is free for up to 10k pageviews/month; after that, the monthly plan starts at $9.
9. GoSquared
GoSquared is another suite of tools, this time aimed at SaaS. Its primary product is its analytics, but it also includes live chat, marketing tools, and a team inbox.
If you’re tired of comparing multiple tools to help make the most of your startup, GoSquared kills several birds with one stone. Perhaps most importantly, if you’re beginning to build a team and don’t have any engineers onboard yet, GoSquared has an award-winning support team and an idiot-proof setup process.
GoSquared has a free plan that’s fine for evaluating the suite and integrating data from day one. As you begin to grow, paid plans start at $40/month.
10. Segment
Segment is a little different from the other analytics tools on this list; Segment is a layer that sits between your site and your analytics. It integrates with many of the tools on this list.
There are several benefits to this approach. The main one is that different teams within your enterprise can access analytics data in a form that suits them — designers can access complex data, and management can stick to revenue flow. It also means that you can switch analytics programs with a single setting in Segment and even migrate historical data into new apps. If you’re an enterprise that wants to future-proof its customer intelligence gathering, Segment is worth considering.
Segment is trusted by some of the web’s best-known names, from IBM to Levis, and…ahem…Google.
Segment is free for up to 1k visitors per month, and after that, the team plan starts at $120/month.
can be position: sticky. It’s pretty easy to make the header of a table stick to the top of the screen while scrolling through a bunch or rows (like this demo).
But stickiness isn’t just for the top of the screen, you can stick things in any scroll direction (horizontal is just as fun). In fact, we can have multiple sticky elements stuck in different directions inside the same element, and even single elements that are stuck in multiple directions.
Here’s a video example of a table that sticks both the header and first column:
Why would you do that? Specifically for tabular data where cross-referencing is the point. In this table (which represents, of course, the scoring baseball game where somehow 20 teams are all playing each other at once because that’s how baseball works), it “makes sense” that you wouldn’t want the team name or the inning number to scroll away, as you’d lose context of what you’re looking at.
CodePen Embed Fallback
Not all tables need to be bi-directionally cross-referenceable. A lot of tables can smash rows into blocks on small screens for a better small-screen experience.
The “trick” at play here is partially the position: sticky; usage, but moreso to me, how you have to handle overlapping elements. A table cell that is sticky needs to have a background, because otherwise we’ll see overlapping content. It also needs proper z-index handling so that when it sticks in place, it’ll be on top of what it is supposed to be on top of. This feels like the trickiest part:
Make sure the tbody>th cells are above regular table cells, so they stay on top during a horizontal scroll.
Make sure the thead>th cells are above those, for vertical scrolling.
Make sure the thead>th:first-child cell is the very highest, as it needs to be above the body cells and it’s sibling headers again for horizontal scrolling.
A bit of a dance, but it’s doable.
High five to Cameron Clark who emailed me demoed this and showed me how cool it is. And indeed, Cameron, it is cool. When I shared that around, Estelle Weyl showed me a demo she made several years ago. That feels about right, Estelle is always a couple of years ahead of me.
Using media queries in CSS as part of responsive websites is bread and butter stuff to todays front-end developer. Using preprocessors to make them more comfortable to write and easier to maintain has become common practice as well.
I spent a few months experimenting with a dozen different approaches to media queries in Sass and actually used a few in production. All of them eventually failed to cater for everything I needed to do in an elegant way. So I took what I liked about each of them and created a solution that covered all scenarios I came across.
Why use a preprocessor at all?
That’s a fair question. After all, what’s the point of doing all this if one can simply write media queries using pure CSS? Tidiness and maintainability.
The most common use for media queries is the transformation of a layout based on the browser’s viewport width. You can make a layout adapt in such a way that multiple devices with different screen sizes can enjoy an optimal experience. As a consequence, the expressions used to define the media queries will make reference to the typical screen width of those devices.
So if your code contains 5 media queries that target tablet devices with a width of 768px, you will hardcode that number 5 times, which is something ugly that my OCD would never forgive. First of all, I want my code to be easy to read to the point that anyone understands instantly that a media query is targeting tablet devices just by looking at it – I reckon the word tablet would do that better than 768px.
Also, what if that reference width changes in the future? I hate the idea of replacing it in 5 instances around the code, especially when it’s scattered around multiple files.
A first step would be to store that breakpoint in a variable and use it to construct the media query.
/* Using plain CSS */
@media (min-width: 768px) {
}
/* Using SCSS variables to store breakpoints */
$breakpoint-tablet: 768px;
@media (min-width: $breakpoint-tablet) {
}
Another reason to write media queries with a preprocessor like Sass is that it can sometimes provide some precious help with the syntax, in particular when writing an expression with a logical or (represented with a comma in CSS).
For example, if you want to target retina devices, the pure CSS syntax starts getting a bit verbose:
/* Plain CSS */
@media (min-width: 768px) and
(-webkit-min-device-pixel-ratio: 2),
(min-width: 768px) and
(min-resolution: 192dpi) {
}
/* Using variables? */
@media (min-width: $bp-tablet) and ($retina) { // or #{$retina}
}
It does look nicer, but unfortunately it won’t work as expected.
A problem with logic
Because of the way the CSS “or” operator works, I wouldn’t be able to mix the retina conditions with other expressions since a (b or c) would be compiled into (a or b) c and not a b or a c.
$retina: "(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)";
// This will generate unwanted results!
@media (min-width: 480px) and #{$retina} {
body {
background-color: red;
}
}
/* Not the logic we're looking for */
@media (min-width: 480px) and (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
body {
background-color: red;
}
}
I realized I needed something more powerful, like a mixin or a function, to address this. I tried a few solutions.
Dmitry Sheiko’s technique
One I tried was Dmitry Sheiko’s technique, which had a nice syntax and includes Chris’ retina declaration.
He has a single-responsibility retina version as well.
But another problem hit me when I was styling an element that required additional rules on intermediate breakpoints. I didn’t want to pollute my list of global breakpoints with case-specific values just so I could still use the mixin, but I definitely didn’t want to forgo the mixin and go back to using plain CSS and hardcoding things every time I had to use custom values.
/* I didn't want to sometimes have this */
@include tablet {
}
/* And other times this */
@media (min-width: 768px) and (max-width: 950px) {
}
Breakpoint technique
Breakpoint-sass was next on my list, as it supports both variables and custom values in its syntax (and, as a bonus, it’s really clever with pixel ratio media queries).
Things were looking better, but I personally think that Breakpoint-sass’ syntax feels less natural than Dmitry’s. You can give it a number and it assumes it’s a min-width value, or a number and a string and it assumes a property/value pair, to name just a few of the combinations it supports.
That’s fine and I’m sure it works great once you’re used to it, but I hadn’t given up on finding a syntax that was both simple and as close as possible to the way I orally describe what a media query must target.
Also, if you look at the example above you’ll see that a device with a width of exactly 768px will trigger both media queries, which may not be exactly what we want. So I added the ability to write inclusive and exclusive breakpoints to my list of requirements.
I’m a fan of Dmitry’s syntax, so my solution was inspired by it. However, I’d like some more flexibility in the way breakpoints are created. Instead of hardcoding the names of the breakpoints in the mixin, I used a multidimensional map to declare and label them.
The mixin comes with a set of default breakpoints, which you can override anywhere in the code by re-declaring the variable $breakpoints.
Inclusive and exclusive breakpoints
I wanted to have a finer control over the intervals in the expressions, so I included support for the less-than-or-equal-to and greater-than-or-equal-to operators. This way I can use the same breakpoint declaration in two mutually exclusive media queries.
@include media(">=phone", "<tablet") {
}
@include media(">=tablet", "<=950px") {
}
/* Compiles to */
@media (min-width: 640px) and (max-width: 767px) {
}
@media (min-width: 768px) and (max-width: 950px) {
}
Infer media types and handle logic disjunction
Similarly to the breakpoints, there’s a list for media types and other static expressions declared by default (which you can override by setting the variable $media-expressions). This adds support for optional media types, such as screen or handheld, but it’s also capable of correctly handling expressions with logical disjunctions, such as the retina media query we saw before. The disjunctions are declared as nested lists of strings.
$media-expressions: (screen: "screen",
handheld: "handheld",
retina2x:
("(-webkit-min-device-pixel-ratio: 2)",
"(min-resolution: 192dpi)")) !default;
@include media("screen", ">=tablet") {
}
@include media(">tablet", "<=desktop", "retina2x") {
}
/* Compiles to */
@media screen and (min-width: 768px) {
}
@media (min-width: 769px) and
(max-width: 1024px) and
(-webkit-min-device-pixel-ratio: 2),
(min-width: 769px) and
(max-width: 1024px) and
(min-resolution: 192dpi) {
}
There’s no rocket science under the hood, but the full implementation of the mixin isn’t something I could show in just a few lines of code. Instead of boring you with huge code snippets and neverending comments, I included a Pen with everything working and I’ll briefly describe the process it goes through to construct the media queries.
CodePen Embed Fallback
How it works
The mixin receives multiple arguments as strings and starts by going through each one to figure out if it represents a breakpoint, a custom width, or one of the static media expressions.
If an operator is found, it is extracted and any matching breakpoint will be returned, or else we assume it’s a custom value and cast it to a number (using SassyCast).
If it’s a static media expression, it checks for any or operators and generates all the combinations necessary to represent the disjunction.
The process is repeated for all the arguments and the results will by glued together by the and connector to form the media query expression.
If you’d like to look at the complete Sass for it, it’s here. It’s called include-media on GitHub.
Final thoughts
I’m a big fan of this technique to make Sass talk to JavaScript. Because we declare breakpoints as a multidimensional list with their names as keys, exporting them in bulk to JavaScript becomes really straightforward and can be done automatically with just a few lines of code.
I’m not trying to put down other people’s solutions and I’m definitely not saying this one is better. I mentioned them to show some of the obstacles I found along the way to my ideal solution, as well as some great things they introduced that inspired my own solution.
You might have some concerns about the length and complexity of this implementation. While I understand, the idea behind it is that you download one single file, @import it into your project and start using it without having to touch the source code. Ping me on Twitter though if you have any questions.
You can get it from GitHub and you are very welcome to contribute with issues/code/love. I’m sure there’s still a lot we can do to make it better.
Update!
Eduardo made a website for his approach: @include-media.
As a web developer, I pay close attention to the design of video games. From the HUD in Overwatch to the catch screen in Pokemon Go to hunting in Oregon Trail, games often have interesting mechanics and satisfying interactions, many of which inspire my own coding games at Codepip.
Beyond that, implementing small slices of these game designs on a web stack is a fun, effective way to broaden your skills. By focusing on a specific element, your time is spent working on an interesting part without having to build out a whole game with everything that entails. And even in this limited scope, you often get exposed to new technologies and techniques that push on the boundaries of your dev knowledge.
As a case study for this idea, I’ll walk you through my recreation of the card swipe from Among Us. For anyone in the dark, Among Us is a popular multiplayer game. Aboard a spaceship, crewmates have to deduce who among them is an imposter. All the while, they complete mundane maintenance tasks and avoid being offed by the imposter.
The card swipe is the most infamous of the maintenance tasks. Despite being simple, so many players have struggled with it that it’s become the stuff of streams and memes.
Here’s my demo
This is my rendition of the card swipe task:
CodePen Embed Fallback
Next, I’ll walk you through some of the techniques I used to create this demo.
Swiping with mouse and touch events
After quickly wireframing the major components in code, I had to make the card draggable. In the game, when you start dragging the card, it follows your pointer’s position horizontally, but stays aligned with the card reader vertically. The card has a limit in how far past the reader it can be dragged to its left or right. Lastly, when you lift your mouse or finger, the card returns to its original position.
All of this is accomplished by assigning functions to mouse and touch events. Three functions are all that‘s needed to handle mouse down, mouse move, and mouse up (or touch start, touch move, and touch end if you‘re on a touchscreen device). Here’s the skeleton of that JavaScript code:
const card = document.getElementById('card');
const reader = document.getElementById('reader');
let active = false;
let initialX;
// set event handlers
document.addEventListener('mousedown', dragStart);
document.addEventListener('mousemove', drag);
document.addEventListener('mouseup', dragEnd);
document.addEventListener('touchstart', dragStart);
document.addEventListener('touchmove', drag);
document.addEventListener('touchend', dragEnd);
function dragStart(e) {
// continue only if drag started on card
if (e.target !== card) return;
// get initial pointer position
if (e.type === 'touchstart') {
initialX = e.touches[0].clientX;
} else {
initialX = e.clientX;
}
active = true;
}
function drag(e) {
// continue only if drag started on card
if (!active) return;
e.preventDefault();
let x;
// get current pointer position
if (e.type === 'touchmove') {
x = e.touches[0].clientX - initialX;
} else {
x = e.clientX - initialX;
}
// update card position
setTranslate(x);
}
function dragEnd(e) {
// continue only if drag started on card
if (!active) return;
e.preventDefault();
let x;
// get final pointer position
if (e.type === 'touchend') {
x = e.touches[0].clientX - initialX;
} else {
x = e.clientX - initialX;
}
active = false;
// reset card position
setTranslate(0);
}
function setTranslate(x) {
// don't let card move too far left or right
if (x < 0) {
x = 0;
} else if (x > reader.offsetWidth) {
x = reader.offsetWidth;
}
// set card position on center instead of left edge
x -= (card.offsetWidth / 2);
card.style.transform = 'translateX(' + x + 'px)';
}
Setting status with performance.now()
Next, I had to determine whether the card swipe was valid or invalid. For it to be valid, you must drag the card across the reader at just the right speed. Didn’t drag it far enough? Invalid. Too fast? Invalid. Too slow? Invalid.
To find if the card has been swiped far enough, I checked the card’s position relative to the right edge of the card reader in the function dragEnd:
let status;
// check if card wasn't swiped all the way
if (x < reader.offsetWidth) {
status = 'invalid';
}
setStatus(status);
To measure the duration of the card swipe, I set start and end timestamps in dragStart and dragEnd respectively, using performance.now().
function setStatus(status) {
// status is only set for incomplete swipes so far
if (typeof status === 'undefined') {
// timestamps taken at drag start and end using performance.now()
let duration = timeEnd - timeStart;
if (duration > 700) {
status = 'slow';
} else if (duration < 400) {
status = 'fast';
} else {
status = 'valid';
}
}
// set [data-status] attribute on reader
reader.dataset.status = status;
}
Based on each condition, a different value is set on the reader’s data-status attribute. CSS is used to display the relevant message and illuminate either a red or green light.
With the core functionality complete, I added a few more touches to get the project looking even more like Among Us.
First, I used a free custom font called DSEG to imitate the segmented type from old LCDs. All it took was hosting the files and declaring the font face in CSS.
Next, I copied the jitter animation of the text in the original. Game developers often add subtle animations to breath life into an element, like making a background drift or a character, well, breathe. To achieve the jitter, I defined a CSS animation:
@keyframes jitter {
from {
transform: translateX(0);
}
to {
transform: translateX(5px);
}
}
At this point, the text glides smoothly back and forth. Instead, what I want is for it to jump back and forth five pixels at a time. Enter the steps() function:
Finally, I added the same audio feedback as used in Among Us.
let soundAccepted = new Audio('./audio/CardAccepted.mp3');
let soundDenied = new Audio('./audio/CardDenied.mp3');
if (status === 'valid') {
soundAccepted.play();
} else {
soundDenied.play();
}
Sound effects are often frowned upon in the web development world. A project like this an opportunity to run wild with audio.
And with that, the we’re done! Here’s that demo again:
CodePen Embed Fallback
Try your own
Given how standardized the web has become in look and feel, this approach of pulling an element from a game and implementing it for the web is a good way to break out of your comfort zone and try something new.
Take this Among Us card swipe. In a small, simple demo, I tinkered with web fonts and animations in CSS. I monkeyed with input events and audio in JavaScript. I dabbled with an unconventional visual style.
Now it’s time for you to survey interesting mechanics from your favorite games and try your hand at replicating them. You might be surprised what you learn.
One of the few bright spots in 2020 has been the creativity companies and individuals alike have exhibited in dealing with what, at times, seemed to be overwhelming problems.
The world of web design was no different. Designers and agencies had to adapt and implement new color schemes or design new shopping experiences, which made some of the previous design trends not fit for the current design problems.
We’ll take a look at these newest design trends and the rationale behind them. As we do so, we’ll also take a look at some of BeTheme’s 600+ pre-built sites that have already put them to good use.
1. Comforting Color Palettes Lighten the Load
In years past, bolder color schemes were one of the hallmarks of web design trends. Their purpose was to quickly engage a visitor and prompt him or her to respond emotionally.
Given all the drama and turmoil we were subjected to through most of 2020, we’ve come to welcome the use of toned-down colors in marketing instead of the bolder, brasher, and more “in-your-face” color schemes.
Bellroy’s website puts toned-down colors to good use. This company’s product line of wallets, bags, and the like, are designed to keep people’s belongings organized, safe, and secure. A wild color scheme simply wouldn’t be fitting.
How, then, are brightly-colored products dealt with? Thanks to judicious uses of white space and background photos, this website still emphasizes a toned-down color palette.
The BeSpa pre-built website is another example of a color scheme that almost immediately puts the mind at ease.
Calm and soothing? Yes.
Boring? Definitely not.
Comfort and security are the emotional drivers in this example.
2. Seamlessly Intermingle and Balance Physical and Digital Imagery
People confined to their homes because of Covid-based restrictions spent many more hours looking at their screens in 2020. Online programming began to take on the appearance of a reality show that blurred the boundaries between the real and the digital.
Whereas web designers tended in the past to rely on either photos or illustrations in their designs, these same designers have started to integrate these blurring effects into their designs, with results that range from amusing and quirky to highly informative.
Check out this example from fashion designer Constance Burke:
It’s not every day you see real models wearing hand-drawn fashion sketches. But it’s just one example of how the physical can be blended with the digital.
The BeSki pre-built site does the same blending of the two, but in a totally different way:
The sections’ designs switch from predominantly physical to largely digital and back again, an excellent approach that provides a maximum amount of useful information.
It’s also worth noting how snowbanks are effectively used to seamlessly transition from one section to the next.
3. Create Well-Organized and Helpful Shopping Experiences
More people spending more time at home has created a surge in online shopping. As a result, many online store owners are now feeling the effects of increased competition.
Consumers look for brands they believe they can trust. At the same time, they want their online shopping experiences to be as quick and painless as possible. They look for (and expect) quick and effective product search capabilities, helpful and effective product displays, one-page product descriptions, and the like.
Walgreen’s product page design is especially well-suited for 2021 ecommerce shoppers:
Everything shoppers usually need to know is presented above-the-fold. They can easily proceed to the next step or scroll down for reviews or additional product specifications.
BePestControl‘s pre-built website uses a similar product design approach:
In this example, the main selling points are up-front and are kept short and sweet. The shopper can either hit the ‘Add to Cart’ button or look below the button for additional information.
In both examples, a visitor doesn’t have to mull over what step to take next since one of the design objectives is to make the shopping experience as easy and as satisfying as possible.
4. Take Advantage of the Benefits of User-Controlled Video Content
Once upon a time, video content was “the thing” to incorporate in a website. Hero background videos proved to be particularly engaging, and “how-to” videos presented much more useful information than illustrations or blocks of text could.
On the other hand, Auto-play videos, those that started on their own, all too often had a tendency to irritate rather than inform, especially when their content didn’t address a visitor’s immediate concern.
Thanks to Zoom and similar video platforms that came into widespread use in 2020 and to website designs that include video “Play” buttons, users have become much more comfortable with the medium. As an example, Shoppers have been given total control over if or when they want to view a given video.
The white “Pay” button is impossible to miss, and while it is designed to encourage a visitor to watch a testimonial, doing so is completely optional.
The BeOptics pre-built website cleverly slips in a video play option as well:
In this example, when visitors hover over the “See More” button, it lets them know that they have the option to watch the video if they want to learn more.
5. Trust Builders Should be Non-Negotiable Web Design Elements
There are various ways in which products are organized or showcased in brick and mortar businesses to instill trust. Helpful and friendly staff also contribute to instilling trust.
Some of these trust-builders are easily incorporated into eCommerce designs. Others, though more difficult to fit in, can usually be satisfactorily addressed.
Digital trust builders can include.
Logos (familiar, whimsical, innovative, engaging)
Portfolios and/or product pages
Customer reviews, product ratings, and client testimonials
Case studies and product or price comparisons
Safety and security seals, e.g., Better Business Bureau, PayPal checkout
Charts, graphs, counters, and other data visualization techniques
Proof of social, charitable, or community-related actions and contributions
Put, trust-building content will beat hard-sell techniques every time, especially if you would like your customer base to include referred and repeat customers.
Omaze, for example, gives people entries for prizes based on their donations while at the same time highlighting the good things it and its donors have brought about.
To help build trust, the site devotes space to highlighting publications that have featured Omaze and the work it has done and is doing.
Plus, it puts data visualization and non-profit testimonials into play to give visitors an added insight into what is going on behind the scenes:
As you can see, it doesn’t have to be difficult to incorporate genuine trust-building content into your website designs.
BePortfolio is a great example of how you might go about doing this for a portfolio site, whether it’s your own or a site for a client:
The home page alone has plenty of space for including trust-building content:
A satisfied customer counter
Product usage case studies and testimonial
Portfolio highlights
Client and partnership logos
And it can only get better as a visitor moves through the site, but only if you’ve chosen to make that happen.
Have You Started to Take These New Web Design Trends to Heart?
We’re not suggesting that you throw the baby out with the bathwater, but some trends will need to be discarded to enable you to adjust to a new normal. Other 2020 design trends, like minimalism and headline topography, are likely to remain popular for years to come.
New trends that incorporate calming color palettes, image blending, more efficient eCommerce UX designs, user-controlled video, and trust-building elements should give your customers the feeling of comfort and security they will be seeking in 2021.
If you want to implement some or all of these new trends in your 2021 website designs, BeTheme’s 600+ pre-built sites make doing so an easy task.
[– This is a sponsored post on behalf of BeTheme –]
Stefan Judis has a “Today I Learned” (TIL) post explaining how SVGs filters can be inlined in CSS. The idea is that CSS has the filter property which supports some built-in functions, like grayscale(100%) and stuff like that.
But it can also point to a filter defined by SVG. So you could do filter: url(#my-custom-filter) which is in some inline as . It’s kinda funny to have to refer out to the HTML like that. A filter is such a visual thing that it makes sense to bring it into the CSS. That looks like this:
Look at all those backslashes (). Makes ya wish CSS had template literals, eh? Makes me nervous that a code formatter or minifier would choke on that, but I don’t actually know, maybe it would be fine.
What’s nice is that the SVG remains fairly intact (readable and editable). So here you can edit the SVG filter in the CSS and have a play:
Filters aren’t the only kind of SVG that makes some sense to inline into CSS though. You can put SVG drawing right into CSS as well.
CodePen Embed Fallback
This works everywhere but Safari in a quick blast through modern browsers. But I think in the not-so-distant past, we needed to encode more of the special characters in the SVG to get it to work (although you didn’t have to resort to base64). Yoskel’s URL-encoder is literally just for this — I just don’t know that it’s necessary anymore.
div {
--angle: 0deg;
/* … */
border-image: linear-gradient(var(--angle), green, yellow) 1;
animation: 10s rotate linear infinite;
}
@keyframes rotate {
to {
--angle: 360deg;
}
}
But wait! That’s not actually going to animate as-is. The browser doesn’t know that 360deg is an actual angle value, and not just some random string. If it did know it was an angle value, it could animate it. So, tell it:
See Bramus’ article for the demos there. Bonafide CSS trick. I can’t wait for more support for @property (Chrome only, as I write), because it really unlocks some cool CSS trickery. Animating numbers visually, for example.
React framework maturity, early container queries, WASM adoption, and monoliths. I’ll take all four, please. Not feeling like a particularly front-end-y? Jay says:
Interestingly, the biggest developments in the front-end are unlikely to be traditionally front-end concerns. Back in our 2019 forecast, we noted that the role of the front-end developer was increasingly shifting towards ‘full-stack’, and this has borne out to be true. Even the evolution of our frameworks and tools suggests this, with an increased focus on data-fetching, concurrency, security and scalability.
If I’m allowed to predict, and thus manifest, improvements in the web platform in 2021, I’d like to predict HTML’s inert attribute shipping without a flag in all three browser engines.
We’re going to try something a little different this month; with this roundup of tools and resources for designers, we’re going to pick a few of our favorites and group everything else in a manner that makes it even easier to find elements that will work for you, and your projects, right now.
Here’s what’s new for designers this month…
February’s Top Picks
Pika
Pika is a new Mac app that is an open-source color picker. It helps you find color swatches on-screen, saving time and design headaches. Plus, it’s packed with bonuses such as the ability to confirm accessibility compliance for colors, compact size and style, easy to access from your desktop, and format-friendly with plenty of color code options.
Iconduck
Iconduck is a searchable database of more than 100,000 icons in one place. (No more searching various marketplaces!) The goal of the project is to make open-source icons and illustrations more accessible. So, everything you find here is free! The site does all the heavy lifting for you by collecting icon sets, tagging them, and making them searchable.
Descript
Descript is a premium tool that eliminates some of the intimidation factors with audio and video editing. With a design that functions as a word document and allows you to transcribe, record the screen, publish, and edit, all with some cool AI features.
Persona
Persona is an all-in-one identity infrastructure that allows you to collect, verify, manage, and decide customer identities from a single dashboard. Everything is fully automated, and most users can be up and running in about 10 minutes. The premium tool does have a free version for small-scale verifications.
6 Productivity Boosters
Peekalink
Peekalink turns standard links into rich content that users will be delighted to share and engage in. And it’s easy to use. Just send a request to the API with a link and get a response back to use, including a rich link for your project.
LinkAce
LinkAce is an open-source and self-hosted archive to store and organize links that you want to save. You can search thanks to tags and lists, and all of the content is available thanks to automated backups and monitoring. There’s a demo you can try before installing it yourself.
Formality
Formality is a WordPress plugin that helps you make forms a little bit easier. It’s made to work with the Gutenberg-based form builder with a single block format to control the form. The plugin has a theme-agnostic design that works with any layout style and includes customizations to make it feel a little more personal.
Wondercall
Wondercall is an embeddable video call system for any website or app. You can make calls and schedule them with a widget you can embed right into your design.
Editor X
The Editor X website builder is out of beta and ready for mainstream use. The platform is designed for designers and agencies to create websites collaboratively and quicker. Features include live commenting, roles and permissions, and shared design libraries. Plus, the platform offers code-free interactions.
Shareful/h2>
Shareful is a Mac app that makes the system share menu more powerful. You can copy, save as, and open indirectly from the system share menu.
2 Icon Sets
Supercons
Supercons is a giant set of icons in React. They are all open-source, and there are plenty of choices to help you propel projects forward.
Plumpy Icons
Plumpy Icons are packed with style. The set of icons has a fun design, comes in duotone colors, and scales to any size. Plus, there are more than 4,000 icons in the collection. There are free and paid options depending on the file type and use.
3 Tutorials and Demos
Noise Planets
Noise Planets is a fun look at plotting random points in a circle to create amazing art pieces. You can generate fun shapes and textures and even animate your results with the tutorial and code snippets’ help.
CSS Polygon Shapes
CSS Polygon Shapes are generated using CSS-doodle and clip-path. You can go in and make adjustments to customize shapes further and use them in your website projects.
Mutsuacen
Mutsuacen is a little app that lets you create animated and interactive drawings. There’s a lot of potential with this tool if you have some true drawing chops, but it not; it’s just fun to play with. Create a doodle or sketch and export.
5 Fresh Fonts and Text Tools
Text Warping – Animated
Text Warping – Animated is a fun effect pen from Lokesh Dhakar. It feels funky while leaving text pretty readable. Play with it for sure.
Gazpacho
Gazpacho is a fun and flexible premium font family with 14 styles from thin to heavy italic. It’s a highly readable serif with a wider stance and great curves.
Stay Home
Stay Home is a simple, line-style all caps font. It has a limited character set but could have some fun applications.
Dogmeal Figure
Dogmeal Figure is an almost silly novelty typeface with dog faces and paw prints in the character set. It might make a fun option for a kids’ project.
Haster
Haster is a futuristic-style slab with a limited character set. It does have shapes and lines with a lot of impact for display use.
Covid Pandemic Lockdown
Covid Pandemic Lockdown is an interesting novelty font with thick lines and a brush-dot style. While it probably won’t read well small, it could be fun as a display option.
Valeria
Valeria is a simple typeface that’s a little wide but has a nice shape and structure. It includes upper- and lowercase letters.
Cornellia
Cornellia is a beautiful script that has amazing letter combinations for use with long swashes and tails. It can add extra elegance to almost any design project instantly.