Archive

Archive for May, 2021

How To Implement Authentication In Next.js With Auth0

May 20th, 2021 No comments

“Authentication” is the action of validating that a user is who he or she claims to be. We usually do this by implementing a credentials system, like user/password, security questions, or even facial recognition.

“Authorization” determines what a user can (or can’t) do. If we need to handle authentication and authorization in our web application, we will need a security platform or module. We can develop our own platform, implement it, and maintain it. Or we can take the advantage of existing authentication and authorization platforms in the market that are offered as services.

When evaluating whether it’s better for us to create our own platform, or to use a third-party service, there are some things that we should consider:

  • Designing and creating authentication services is not our core skill. There are people working specially focused on security topics that can create better and more secure platforms than us;
  • We can save time relying on an existing authentication platform and spend it adding value to the products and services that we care about;
  • We don’t store sensitive information in our databases. We separate it from all the data involved in our apps;
  • The tools third-party services offer have improved usability and performance, which makes it easier for us to administrate the users of our application.

Considering these factors, we can say that relying on third-party authentication platforms can be easier, cheaper, and even more secure than creating our own security module.

In this article, we will see how to implement authentication and authorization in our Next.js applications using one of the existing products in the market: Auth0.

What Is Auth0?

It allows you to add security to apps developed using any programming language or technology.

“Auth0 is a flexible, drop-in solution to add authentication and authorization services to your applications.”

Dan Arias, auth0.com

Auth0 has several interesting features, such as:

  • Single Sign-On: Once you log into an application that uses Auth0, you won’t have to enter your credentials again when entering another one that also uses it. You will be automatically logged in to all of them;
  • Social login: Authenticate using your preferred social network profile;
  • Multi-Factor Authentication;
  • Multiple standard protocols are allowed, such as OpenID Connect, JSON Web Token, or OAuth 2.0;
  • Reporting and analytics tools.

There is a free plan that you can use to start securing your web applications, covering up to 7000 monthly active users. You will start paying when the amount of users increases.

Another cool thing about Auth0 is that we have a Next.js SDK available to use in our app. With this library, created especially for Next.js, we can easily connect to the Auth0 API.

Auth0 SDK For Next.js

As we mentioned before, Auth0 created (and maintains) a Next.js focused SDK, among other SDKs available to connect to the API using various programming languages. We just need to download the NPM package, configure some details about our Auth0 account and connection, and we are good to go.

This SDK gives us tools to implement authentication and authorization with both client-side and server-side methods, using API Routes on the backend and React Context with React Hooks on the frontend.

Let’s see how some of them work in an example Next.js application.

Example Next.js App Using Auth0

Let’s go back to our previous video platform example, and create a small app to show how to use Auth0 Next.js SDK. We will set up Auth0’s Universal Login. We will have some YouTube video URLs. They will be hidden under an authentication platform. Only registered users will be able to see the list of videos through our web application.

Note: This article focuses on the configuration and use of Auth0 in your Next.js application. We won’t get into details like CSS styling or database usage. If you want to see the complete code of the example app, you can go to this GitHub repository.

Create Auth0 Account And Configure App Details

First of all, we need to create an Auth0 account using the Sign Up page.

After that, let’s go to the Auth0 Dashboard. Go to Applications and create a new app of type [“Regular Web Applications”].

Now let’s go to the Settings tab of the application and, under the Application URIs section, configure the following details and save the changes:

  • Allowed Callback URLs: add http://localhost:3000/api/auth/callback
  • Allowed Logout URLs: add http://localhost:3000/

By doing this, we are configuring the URL where we want to redirect the users after they login our site (Callback), and the URL where we redirect the users after they log out (Logout). We should add the production URLs when we deploy the final version of our app to the hosting server.

Auth0 Dashboard has many configurations and customizations we can apply to our projects. We can change the type of authentication we use, the login/sign-up page, the data we request for the users, enable/disable new registrations, configure users’ databases, and so on.

Create Next.js App

To create a brand new Next.js app, we will use create-next-app, which sets up everything automatically for you. To create the project, run:

npx create-next-app [name-of-the-app]

Or

yarn create next-app [name-of-the-app]

To start the develop server locally and see the site just created in your browser, go to the new folder that you created:

cd [name-of-the-app]

And run:

npm run dev

Or

yarn dev

Install And Configure The Auth0 Next.js SDK

Let’s install the Auth0 Next.js SDK in our app:

npm install @auth0/nextjs-auth0

Or

yarn add @auth0/nextjs-auth0

Now, in our env.local file (or the environment variables menu of our hosting platform), let’s add these variables:

AUTH0_SECRET="[A 32 characters secret used to encrypt the cookies]"
AUTH0_BASE_URL="http://localhost:3000"
AUTH0_ISSUER_BASE_URL="https://[Your tenant domain. Can be found in the Auth0 dashboard under settings]"
AUTH0_CLIENT_ID="[Can be found in the Auth0 dashboard under settings]"
AUTH0_CLIENT_SECRET="[Can be found in the Auth0 dashboard under settings]"

If you want more configuration options, you can take a look at the docs.

Create the Dynamic API Route

Next.js offers a way to create serverless APIs: API Routes. With this feature, we can create code that will be executed in every user request to our routes. We can define fixed routes, like /api/index.js. But we can also have dynamic API routes, with params that we can use in our API routes code, like /api/blog/[postId].js.

Let’s create the file /pages/api/auth/[...auth0].js, which will be a dynamic API route. Inside of the file, let’s import the handleAuth method from the Auth0 SDK, and export the result:

import { handleAuth } from '@auth0/nextjs-auth0';

export default handleAuth();

This will create and handle the following routes:

  • /api/auth/login
    To perform login or sign up with Auth0.
  • /api/auth/logout
    To log the user out.
  • /api/auth/callback
    To redirect the user after a successful login.
  • /api/auth/me
    To get the user profile information.

And that would be the server-side part of our app. If we want to log in to our application or sign up for a new account, we should visit http://localhost:3000/api/auth/login. We should add a link to that route in our app. Same for logging out from our site: Add a link to http://localhost:3000/api/auth/logout.

Add The UserProvider Component

To handle user authentication state on the frontend of our web application we can use UserProvider React component, available on Auth0 Next.js SDK. the component uses React Context internally.

If you want to access the user authentication state on a Component, you should wrap it with a UserProvider component.

<UserProvider>
  <Component {...props} />
</UserProvider>

If we want to access all of the pages in our application, we should add the component to the pages/_app.js file. pages/_app.js overrides the React App component. It’s a feature that Next.js exposes to customize our application. You can read more about it here.

import React from 'react';
import { UserProvider } from '@auth0/nextjs-auth0';

export default function App({ Component, pageProps }) {
  return (
    <UserProvider>
      <Component {...pageProps} />
    </UserProvider>
  );
}

We have a React hook useUser that accesses to the authentication state exposed by UserProvider. We can use it, for instance, to create a kind of welcome page. Let’s change the code of the pages/index.js file:

import { useUser } from "@auth0/nextjs-auth0";

export default () => {
 const { user, error, isLoading } = useUser();

 if (isLoading) return <div>Loading...</div>;

 if (error) return <div>{error.message}</div>;

 if (user) {
   return (
     <div>
       <h2>{user.name}</h2>
       <p>{user.email}</p>
       <a href="/api/auth/logout">Logout</a>
     </div>
   );
 }
 return <a href="/api/auth/login">Login</a>;
};

The user object contains information related to the user’s identity. If the person visiting the page is not logged in (we don’t have a user object available), we will display a link to the login page. If the user is already authenticated, we will display user.name and user.email properties on the page, and a Logout link.

Let’s create a videos.js file, with a list of three YouTube video URLs that will only be visible for registered people. To only allow logged users to see this page, we will use withPageAuthRequired method from the SDK.

import { withPageAuthRequired } from "@auth0/nextjs-auth0";

export default () => {
 return (
   <div>
     <a href="https://www.youtube.com/watch?v=5qap5aO4i9A">LoFi Music</a>
     <a href="https://www.youtube.com/watch?v=fEvM-OUbaKs">Jazz Music</a>
     <a href="https://www.youtube.com/watch?v=XULUBg_ZcAU">Piano Music</a>
   </div>
 );
};

export const getServerSideProps = withPageAuthRequired();

Take into consideration that our web application allows any person to sign up for an account, using the Auth0 platform. The user can also re-use an existing Auth0 account, as we’re implementing Universal Login.

We can create our own registration page to request more details about the user or add payment information to bill them monthly for our service. We can also use the methods exposed in the SDK to handle authorization in an automatic way.

Conclusion

In this article, we saw how to secure our Next.js applications using Auth0, an authentication and authorization platform. We evaluate the benefits of using a third-party service for the authentication of our web applications compared to creating our own security platform. We created an example Next.js app and we secured it using Auth0 free plan and Auth0 Next.js SDK.

If you want to deploy an Auth0 example application to Vercel, you can do it here.

Further Reading And Resources

Categories: Others Tags:

6 Ways Parallax Still Works in 2021 

May 19th, 2021 No comments

Parallax is a term that is applied loosely and frequently in the world of web design. As a trend, it has been popular and unpopular in equal measures for some time. However, it’s still one of the most valuable tools for animation in the digital world.

Parallax creates an illusion of depth when scrolling, a timeless effect that still has lots of value in the web design world.

Sure, parallax has its issues, from problems with usability, to concerns with mobile responsivity — but it’s also an interesting way to make a website stand out when done correctly.

Let’s take a closer look at some of the ways that parallax scrolling still works in 2021…

1. Parallax Tells A Story

Let’s start simple. 

One of the most effective ways to use parallax scrolling in the modern age is to tell a story. Today’s consumers want to have an emotional connection with the brands they buy from – now more than ever. Five years ago, studies showed that around 80% of customers want brands to tell stories, and that trend remains consistent to this day.

In the age of digital consumerism, where people can’t get to know a company in person through face-to-face interactions with its salespeople, companies need new ways to connect with their clients. Telling brand-driven stories is a way to highlight that your company is more than just a faceless entity – it’s something with real soul. 

Let’s look at the “Recap After Use” website, a portfolio belonging to the innovative Louie Sellers. This website showcases Louie’s skills with attention-grabbing visuals, including a parallax animation that makes it looks like Louie is drawing the page as you scroll through it.

This is the kind of exceptional animation that makes parallax scrolling more compelling. The animation isn’t there to make a visual difference to the page – it tells you something more about the person behind the website and what they can do.

2. Parallax Increases Website Visit Times

If a website effectively tells a story with parallax animation, you can also bet that’s going to keep customers or readers on a page for longer. Reducing bounce rate by increasing engagement is one of the main goals of any web designer. (Bounce rates, of course, refer to the percentage of site visitors that hit the back button after just seeing the first page of your website.)

While some people argue that parallax websites can hurt your SEO rankings if they slow down your site, there’s also the argument that the lack of a visually engaging page can harm SEO. Bounce rates drag down your ranking and make it harder to get audience attention. 

A parallax animation that tells a story and engages your audience through carefully delivered information is a great way to keep people around – even just for a little longer than usual. For instance, if you check out Alex Dram’s portfolio page here, you’ll see several shapes coming together during the parallax scrolling animation.

The shapes merge to tell a story about the visual experiences that Alex can create for customers. It’s a way to draw the eye and connect with the viewer without just writing about what you do through text. 

3. Parallax Develops Credibility

There’s a reason why both examples of parallax scrolling we’ve looked at so far are from creative portfolios. Parallax scrolling, with its excellent storytelling capabilities, is great for demonstrating your credibility as a digital expert. Basically, it’s a version of “showing” and not “telling” customers about your skills. 

You can tell someone that you know how to use tricky techniques like parallax animation correctly, but they’re less likely to believe you that way. If you can show that you have the skills to create something amazing, that’s more engaging. 

The OK Alpha team is a great company to reference when it comes to sensational design. This company seems to always be on the cutting edge of the latest trends, whether it’s bold typography or bright colors. To add to the impact of their website, the company has combined parallax effects into the mix to make everything more immersive as you scroll. 

This is a beautiful example of how companies in the design landscape can use techniques like parallax scrolling to show what they’re capable of. 

4. Parallax Makes Information More Fun

Most of us are naturally visual learners. We like to consume information in a way that’s refreshingly eye-catching and attractive. That’s why visual content generally earns more social shares and attention than written content. With parallax scrolling, companies that want to deliver valuable information and educational content to their audience can do so effectively.

Rather than just scrolling through a page and seeing lots of text, your customers can see images and graphs come to life alongside the blocks of text they’re reading. It’s like adding video demonstrations next to a textbook to help people better understand what they’re reading about. 

Look at the Web Design and Art History microsite from Webflow as an example. The company wants you to understand how web design and art have evolved over the years, but it doesn’t want to deliver that information in a boring format. The bright graphics and parallax animation work together to give you a more contextual, meaningful experience.

5. Parallax Replicates Another Medium

What if you could remind someone of their experience when reading a book or watching a video while telling them about a video or a novel? Parallax scrolling and animation can help with that. It’s a way of making your website feel like a video presentation or slideshow without the added components of implementing video players into your back end. 

Parallax scrolling also has another slight benefit over a standard video-based website. On a website that uses a video for a background, the video often plays automatically. This means that your visitors can’t control how quickly the video plays. 

On the other hand, parallax animations driven by scrolling action allow your customer to collect information at a pace that suits them. Take a look at the Story of the Goonies website, for instance. This stunning parallax site introduces you to the details you need to know about the movie in a way that makes it feel like the intro to a film.

The great thing about the parallax on this site is that the slow video-style design also gives you a dose of nostalgia – which ties in perfectly with the movie. 

6. Parallax Is More Memorable

What’s the main reason any designer does anything special to a website? To make it stand out, of course. Web design is all about conveying the unique essence of a brand, business, or entity in a way that’s going to make that client unforgettable. Although parallax isn’t as novel as it once was, it can still be a way to make your site stand out – if it’s used correctly. 

The key to success with parallax scrolling for memorability is making it smart. The layout needs to feel simple and intuitive. Everything needs to work well together, from the lightly shifting font to the various parallax effects that work together to draw the viewer’s eye (and attention). 

A great example comes from Jomor Design – another designer with a portfolio that really grabs your focus from the first second. The layout is beautifully done, with plenty of mini moments for engagement and interactions throughout. As you scroll through the site, you get a better idea of what the designer is all about. The little moments of animation make the whole experience so much more memorable. 

When your site is more memorable and engaging than that of your competition, you can drive many major benefits for your brand, including an improved bounce rate.

What To Remember When Using Parallax

Parallax is just like any other design technique. There are ways you can do it wonderfully, which engage and delight your audience. However, there are also a lot of areas where you can easily go wrong. When using any design element, the main thing to remember is that the primary focus should always be your users’ experiences. Parallax shouldn’t just be a way to show off your design knowledge. It’s just another feature that you can use to create an amazing website. 

Remember that user experience and visual appeal need to work perfectly together for parallax to work. If scrolling through the page is practically impossible for people on a mobile device, then you’re not going to get the results you want. If it’s difficult to take in the message you’re trying to send because the content is moving too quickly, again, your users will suffer. 

Remember the following tips:

  • Simple is better: Reduce the amount of content and visual elements on your page whenever you can. The less information there is to capture your customer’s attention, the less likely it is that you’re going to end up with a problem. 
  • Compress file sizes: Make sure that you’re not reducing the speed of your website by creating a huge single page with tons of high-quality images. You’re going to need to use the smallest possible file sizes. 
  • Check responsiveness: Make sure that the parallax effect works just as well on your smartphone or tablet as it would on a desktop. As more people move their browsing experiences into their palms, you can’t afford to ignore responsivity. 
  • Find the “wow”: Look at these examples of parallax websites. Every one stands out because it does something special with the scrolling effect. If you’re going to be using this strategy with your website, you need to make sure it’s worth the effort. Don’t just follow the same guidelines as everything else. Find the idea that’s going to make people take notice.

Source

The post 6 Ways Parallax Still Works in 2021  first appeared on Webdesigner Depot.

Categories: Designing, Others Tags:

svg-loader: A Different Way to Work With External SVG

May 19th, 2021 No comments

SVGs are awesome: they are small, look sharp on any scale, and can be customized without creating a separate file. However, there is something I feel is missing in web standards today: a way to include them as an external file that also retains the format’s customization powers.

For instance, let’s say you want to use your website’s logo stored as web-logo.svg. You can do:

<img src="/images/logo.svg" />

That’s fine if your logo is going to look the same everywhere. But in many cases, you have 2-3 variations of the same logo. Slack, for example, has two versions.

Even the colors in the main logo are slightly different.

If we had a way to customize fill color of our logo above, we could pass any arbitrary color to render all the variations.

Take the case of icons, too. You wouldn’t want to do something like this, would you?

<img src="/icons/heart-blue.svg" />
<img src="/icons/heart-red.svg" />

Load external SVGs as inline elements

To address this, I have created a library called svg-loader. Simply put, it fetches the SVG files via XHR and loads them as inline elements, allowing you to customize the properties like fill and stroke, just like inline SVGs.

For example, I have a logo on my side-project, SVGBox. Instead of creating a different file for every variation, I can have one file and customize the fill color:

CodePen Embed Fallback

I used data-src to set the URL of SVG file. The fill attribute overrides fill of the original SVG file.

To use the library, the only thing I have to ensure is that files being served have appropriate CORS headers for XHRs to succeed. The library also caches the files locally, making the subsequent much faster. Even for the first load, the performance is comparable to using tags.

This concept isn’t new. svg-inject does something similar. However, svg-loader is easier to use as we only have to include the library somewhere in your code (either via a tag, or in the JavaScript bundle). No extra code is needed.

Dynamically-added elements and change in attributes are also handled automatically, which ensures that it works with all web frameworks. Here’s an example in React:

But why?

This approach may feel unorthodox because it introduces a JavaScript dependency and there are already multiple ways to use SVGs, including inline and from external sources. But there’s a good case for using SVGs this way. Let’s examine them by answering the common questions.

Can we not just inline SVG ourselves?

Inlining is the simplest way to use SVGs. Just copy and paste the SVG code in the HTML. That’s what svg-loader is ultimately doing. So, why add the extra steps to load a SVG file from somewhere else? There are two major reasons:

  1. Inline SVGs make the code verbose: SVGs can be anywhere from a few lines to a few hundred. Inline SVGs can work well if what you need is just a couple of icons and they are all tiny. But it becomes a major pain if they are sizeable or many, because then, they become long strings of text in code that isn’t “business logic.” The code becomes hard to parse.

    It’s the same thing as preferring an external stylesheet over a tag or using images instead of data URIs. It’s no wonder that in React codebases, the preferred approach is to use SVG as a separate component, rather than define it as a part of JSX.

  1. External SVGs are much more convenient: Copying and pasting often does the job, but external SVGs can be really convenient. Say you’re experimenting with which icon to use in your app. If you’re using inline SVGs, that means going back and forth to get the SVG code. But with external SVGs, you only have to know the name of the file.

    Take a look at this example. One of the most extensive icon repository on GitHub is Material Design Icons. With svg-loader and unpkg, we can start using any of 5,000+ icons right away.

CodePen Embed Fallback

Isn’t it inefficient to trigger an HTTP request for every SVG versus making a sprite?

Not really. With HTTP2, the cost of making an HTTP request has become less relevant. Yes, there are still benefits of bundling (e.g., better compression), but for non-blocking resources and XHRs, the pros are almost non-existent in real-world scenarios.

Here’s a Pen loading 50 icons in a similar fashion as above. (Open in incognito mode as the files are cached by default):

CodePen Embed Fallback

What about tag (SVG symbols)?

SVG symbols separate the definition of the SVG file from its use. Instead of defining the SVG everywhere, we can have something like this:

<svg>
  <use xlink:href="#heart-icon" />
</svg>

The problem is that none of the browsers support using symbols files hosted on a third-party domain. Therefore, we can’t do something like this:

<svg>
  <use xlink:href="https://icons.com/symbols.svg#heart-icon" />
</svg>

Safari doesn’t even support symbols files hosted on the same domain.

Can we not use a build tool that inlines the SVGs?

I couldn’t find an obvious way to fetch SVGs from a URL and inline them in common bundlers, like webpack and Grunt, although they exist for inlining SVG files stored locally. Even if a plugin that does this exists, setting up bundlers isn’t exactly straightforward. In fact, I often avoid using them until the project has reached acertain level of complexity. We must also realize that a majority of the internet is alien to things like webpack and React. Simple scripts can have a much wider appeal.

What about the tag?

The tag is a native way to include external SVG files that work across all the browsers.:

<object data="https://unpkg.com/mdi-svg@2.2.43/svg/access-point-network.svg" width="32" height="32"></object>

However, the drawback is we’re unable to customize the SVG’s attributes unless it’s hosted on the same domain (and the tag doesn’t respect CORS headers). Even if the file is hosted on the same domain, we’d require JavaScript to manipulate the fill, like this:

<object data="https://unpkg.com/mdi-svg@2.2.43/svg/access-point-network.svg" width="32" height="32" onload="this.contentDocument.querySelector('svg').fill = 'red'"></object>

In short, using external SVG files this way makes it ultra-convenient to use icons and other SVG assets. As covered earlier, with unpkg, we can use any icon on GitHub without needing extra code. We can avoid creating a pipeline in a bundler to process SVG files or a component for every icon, and just host the icons on a CDN.

Loading SVG files this way packs a lot of benefits with very little cost.


The post svg-loader: A Different Way to Work With External SVG appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

Frustrating Design Patterns: Mega-Dropdown Hover Menus

May 19th, 2021 No comments

Complex websites often rely on complex navigation. When a website houses thousands of pages, often combined with micro-websites and hundreds of subsections, eventually the navigation will go deep and broad. And with such a complex multi-level navigation, showing the breadth of options requires quite a bit of space. Think of large eCommerce retailers and large corporate sites, catering to many audiences and having plenty of entry points.

No wonder that a common way to deal with this complexity is to expose customers to a large amount of navigation quickly. That’s exactly why mega-dropdowns have become somewhat an institution on the web — albeit mostly for complex and large projects. A mega-dropdown is essentially a large overlay that appears on a user’s action. Usually it includes a mixed bag of links, buttons, thumbnails and sometimes nested dropdowns and overlays on its own.

For decades, a common behavior for this kind of navigation is to open the menu on mouse hover. And for decades, a common user’s complaint about this pattern has been the absolute lack of certainty and control about how and when the sub-navigation opens and closes.

Sometimes the submenu appears unexpectedly, and sometimes it suddenly disappears, and sometime it stays on the screen for a while, although the mouse pointer is already in a very different part of the page, or on another page altogether.

Why Are Mega-Dropdowns Hover Menus Frustrating?

The main reason why mega-dropdowns can be cumbersome to use is because of a mismatch of intentions and expectations. With hover menus, we try to deduce and act on a particular intent by tracking mouse behavior, yet our customers might have very different objectives and very different limitations when accessing a page.

Customer’s behavior is usually unpredictable, even although our analytics might tell a slightly different story with data points gathered and normalized over a longer period of time. We just rarely can predict behavior accurately.

The common scenarios we usually explore are:

  1. The customer is aiming at the category link and travels there directly to explore the sub-navigation items in that category.
  2. The customer is moving the mouse towards a target on the screen, but the trajectory that the mouse has to travel covers a nav link that opens a mega-dropdown.

However, there are also plenty of other situations to consider. Just to name a few:

  1. The customer wants to look up mega-dropdown options while typing in a search autocomplete. To do that, they have to keep re-opening mega-dropdown, or use separate browse tabs, positioned side by side.
  2. The customer might use a trackpad (or a mouse) to operate a large secondary display, so pointer movements will be slower, abrupt and inaccurate. This would cause the mega-dropdown to open involuntarily every time the user pauses when traveling to CTAs or shopping cart at the top of the page.
  3. The customer wants to open the category page, so they travel to the category link, click on it, but experience flickering because a mega-dropdown appears delayed.
  4. With nested sub-menus within a mega-dropdown, the customer wants to explore similar items within the category in which they currently are, but because of nesting, they have to re-open the mega-dropdown over and over again, and travel the same hover tunnel over and over again.
  5. Imagine a situation when you want to resize the window, and just as you are about to snap to the right edge of the window, a hover menu keeps showing up — just because you’ve moved your mouse cursor too closely.
  6. The user starts scrolling down slowly to assess the content on a page, but the menu keeps popping up. And every time the user bumps away a cursor to read the contents of the mega-dropdown, the menu accidentally disappears.

The problem is that we need to support all these intentions and all these accidents, but at the same time we need to make sure that we don’t create an annoying and frustrating experience for any of these cases either. Of course, as designers and developers, we’ve invented a number of techniques to tackle this problem.

Hover Entry/Exit Delay

One of the first solutions, and also one of the most common ones still, is to introduce a hover entry/exit delay. We need to make sure that the enu mdoesn’t open and doesn’t close too early. To achieve that, we introduce a delay, usually around 0.5 seconds. That means that we give customers a buffer of around 0.5 seconds to:

  • Cross the trajectory to a remote target if needed, or
  • Indicate that they intent to explore the navigation by remaining on the mega-dropdown category link, or
  • Correct a mistake if they left the boundaries of a mega-dropdown by accident.

In other words, as long as the customer stays within the mega-dropdown overlay, we keep displaying it. And we hide the overlay once the customer has moved their mouse cursor outside of the sub-navigation overlay for at least 0.5 seconds.

While it solves the problem of accidental flickering on the page, it introduces a lag in cases when a user has left the mega-dropdown for more than 0.5 seconds. As a result, it slows down every interaction with the mega-dropdown across the entire site. Unfortunately, it becomes very quickly very noticeable, especially if the navigation is used a lot.

As long as the user stays within the triangle or within the entire mega-dropdown area, the overlay is still displayed. If the user chooses to travel outside of the triangle, the content of the mega-dropdown overlay will change accordingly. And of course it will disappear altogether immediately once the user has moved outside of the category list altogether.

Chris Coyier highlights some of the technical intricacies of this technique in his post on Dropdown Menus with More Forgiving Mouse Movement Paths, along with a vanilla JavaScript demo by Alexander Popov on “Aim-Aware Menus”.

With this technique we minimize the friction of sudden disappearance and re-appearance of sub-navigation. But it might become ineffective if category links are positioned too close to each other, or we display the hover menu by hovering over a larger button. We can do a bit better with SVG path exit areas.

SVG Path Exit Areas

When calculating a trajectory triangle with the previous technique, sometimes we would not only track the exact position of the mouse pointer, but also recalculate the triangle with every pointer movement — all the time. We can improve the strategy by calculating the overall SVG overlay area once and track whether the mouse pointer is inside it — without recalculating the triangle all the time. A great example of it is Hakim el Hattab’s implementation that draws the areas dynamically with SVG based on the position of the navigation item on the screen.

Hakim’s solution is actually responsive, so if the sub-navigation doesn’t fit on the screen, it will float next to the main navigation item, displayed in full width or height. The SVG path area will be recalculated accordingly, but only if the user scrolls vertically or horizontally. You can see a working demo of the technique in action on Hakim’s debug view mode of the Menu pattern.

In case you do have to deal with a complex navigation of this kind, it might be worth testing if issues disappear when only one (rather than two) hover menu is used. That menu would be slightly larger and house all options within columns. Or if possible, for every category, consider displaying all navigation options within that category as a permanent navigation bar (sidebar or a sticky top bar) — usually it should eliminate all these issues altogether.

Category titles doing too many things

As we’ve seen previously, sometimes category titles have two different functions. On the one hand, each category title could be linked to the category’s page, so customers could click on them to go straight to the page. On the other hand, they also could open a mega-dropdown overlay. So if the user is hovering over the title for a long enough time, the mega-dropdown will open, but the user might have clicked on a link already, and this will cause flickering. For customers, it’s difficult to have the right expectations when the interface doesn’t really provide any hints.

There are a few options to resolve this problem:

  1. To indicate that the category’s title is a link, it might be helpful to underline it,
  2. To make the distinction between the category title and a dropdown more obvious, add a vertical separator (e.g. vertical line) and an icon (chevron),
  3. Leave the category’s title opening only the mega-dropdown, and add a link to the category’s “Home” section within the mega-dropdown overlay. It could also be a prominent “See all options” button instead (see The Guardian example above).

As mentioned above, sometimes you can see an extra icon being used to indicate that the menu opens an overlay, while the category’s title is a link. In our usability tests, we noticed that whenever an icon is present (and it doesn’t matter which icon that is), users often make a mental distinction between the action that will be prompted by a click on an icon, and the action prompted by a click on the category title.

In the former case, they usually expect a dropdown to open, and in the latter case, the category page to appear. More importantly, they seem to expect the menu to open on tap/click, rather than hover.

If you are looking for a technical implementation, you can check In Praise of the Unambiguous Click Menu, in which Mark Root-Wiley shows how to build an accessible click menu. The idea is to start building the menu as a CSS-only hover menu that uses li:hover > ul and li:focus-within > ul to show the submenus.

Then, we use JavaScript to create the

Categories: Others Tags:

Pinned Audio WordPress Theme

May 18th, 2021 No comments

I’m afraid I have to start this with a whole backstory, as the journey here is the point, not so much the theme.

A fella wrote to me a while back outlining a situation he was in. His company has a bunch of WordPress sites for public radio, many of which are essentially homes for podcasts. There is one specific bit of functionality he thought would be ideal for them all: to have a “pinned” audio player. Like you could play a podcast, then continue navigating around the site without that podcast stopping.

This is somewhat tricky to pull off in WordPress, because WordPress does full page reloads like any other regular website not doing anything special with link handling or history manipulation. When a page reloads, any audio on the page stops playing. That’s just how the web works.

So how would you pull it off on a WordPress site? Well, you could make it a headless WordPress site and rebuild the entire front-end as a Single Page App. Sounds fun to me, but I’d be hesitant to make that call just for this one thing.

What else could you do? You could find a way to make the page never reload. I remember doing this on a little static site 10 years ago, but that wasn’t a full blown WordPress site and I didn’t even bother updating the URL back then.

What if you did this…

  1. Intercept internal link clicks
  2. Ajax’d the content from that URL
  3. Replaced the content on the page with that new content

I’ll do this in jQuery quick for ya:

$("a").on("click", () => {
  const url = $(this).attr("href");
  $.get(url + " main", (data) => {
    $("main").html(data);
    history.pushState({}, "", url);
  });
});

That’s not far off from being literally functional. You’d wanna watch for a popstate event to deal with the back button, but that’s only a few more lines.

In this hypothetical world, you’d lay out the site like:

<html>
<!-- ... -->

<body>
   <main></main>
   <audio src="" controls ...></audio>
</body>
</html>

So all that content gets swapped out, the URL changes, but your player is left alone to keep playing in peace. You’d write more JavaScript to give people a way to update what podcast is playing and such.

Turns out there is more to think about here though. Are any inline scripts on the content going to run? What about updating the </code> too? There are enough edge concerns you probably will get annoyed dealing with it. </p> <p>I wanted to have a play with this stuff, so I tossed together a WordPress theme and reached for <a target="_blank" href="https://turbo.hotwire.dev/" rel="noopener">Turbo</a> instead of hand-writing something. Turbo (the new version of Turbolinks) is designed just for this. It’s a JavaScript library you drop on the page (no build process, no config) and it just works. It intercepts internal link clicks, Ajax’s for new content, etc. But it has this interesting feature where if you put a <code>data-turbo-permanent</code> attribute on an HTML element, it will persist it across that reload. So I <a target="_blank" href="https://github.com/chriscoyier/PinnedAudio/blob/main/header.php" rel="noopener">did that for the audio player here</a>. </p> <p>Here’s the thing though. </p> <p>I just don’t have time to finish this project properly. It was fun to have a play, but my interest in it has kinda petered out. So I’ll leave it alone for now:</p> <div class="wp-block-buttons"> <div class="wp-block-button"><a target="_blank" class="wp-block-button__link" href="https://pinned-audio.flywheelsites.com/" rel="noopener">Live Demo</a></div> <div class="wp-block-button"><a target="_blank" class="wp-block-button__link" href="https://github.com/chriscoyier/PinnedAudio" rel="noopener">GitHub Repo</a></div> </div> <p>It <em>almost</em> works, minus one glaring bug that the audio stops playing on the first navigation, then works after that. I’m sure it’s fixable, but I just don’t have much skin in this game. I figure I’ll just bow out and leave this code around for someone to pick up if it’s useful for them.</p> <p>Another thing at play here is that Turbo is from Basecamp, and Basecamp has <a target="_blank" href="https://www.theverge.com/2021/5/4/22419512/basecamp-political-speech-policy-fallout" rel="noopener">rather imploded</a> recently making it not feel great to be using their software. Exacerbated by the fact that Sam Stephenson <a target="_blank" href="https://twitter.com/sstephenson/status/1392533097204404240" rel="noopener">wrote 75% of Turbo</a> and has said he won’t be touching it (or other related projects) unless the software is moved to its own foundation. Turbo was already in a shaky place since it seemed <a target="_blank" href="https://github.com/hotwired/turbo/issues/221" rel="noopener">buggy</a> compared to Turbolinks, and now is on <em>very</em> gnarly ground.</p> <hr> <p>The post <a target="_blank" rel="nofollow noopener" href="https://css-tricks.com/pinned-audio-wordpress-theme/">Pinned Audio WordPress Theme</a> appeared first on <a target="_blank" rel="nofollow noopener" href="https://css-tricks.com/">CSS-Tricks</a>.</p> <p>You can support CSS-Tricks by being an <a target="_blank" href="https://css-tricks.com/product/mvp-supporter/" rel="noopener">MVP Supporter</a>.</p> <div class="fixed"></div> </div> <div class="under"> <span class="categories">Categories: </span><span><a href="http://www.webmastersgallery.com/category/design/" rel="category tag">Designing</a>, <a href="http://www.webmastersgallery.com/category/uncategorized/" rel="category tag">Others</a></span> <span class="tags">Tags: </span><span></span> </div> </div> <div class="post" id="post-4083382"> <h2><a class="title" href="http://www.webmastersgallery.com/2021/05/18/smashing-podcast-episode-37-with-adam-argyle-what-is-visbug/" rel="bookmark">Smashing Podcast Episode 37 With Adam Argyle: What Is VisBug?</a></h2> <div class="info"> <span class="date">May 18th, 2021</span> <span class="author"></span> <span class="comments"><a href="http://www.webmastersgallery.com/2021/05/18/smashing-podcast-episode-37-with-adam-argyle-what-is-visbug/#respond">No comments</a></span> <div class="fixed"></div> </div> <div class="content"> <div class="ftpimagefix" style="float:left"><a target="_blank" href="0" rel="noopener"><img decoding="async" src="https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/48b398db-d094-45ac-aaf2-d2321f2a0c32/adam-argyle-opt.jpg"></a></div> <p>In this episode, we’re talking about VisBug. What is it, and how is it different from the array of options already found in Chrome DevTools? Drew McLellan talks to its creator Adam Argyle to find out.</p> <h3>Show Notes</h3> <ul> <li><a target="_blank" href="https://visbug.web.app/" rel="noopener">VisBug sandbox and playground</a></li> <li>Adam on <a target="_blank" href="https://twitter.com/argyleink" rel="noopener">Twitter</a></li> <li>Adam’s <a target="_blank" href="https://nerdy.dev/" rel="noopener">personal site</a></li> <li><a target="_blank" href="https://t.co/bVWVxz4QcL?amp=1" rel="noopener">VisBug on YouTube</a></li> <li><a target="_blank" href="https://medium.com/dev-channel/visbug-101-749f26a485c8" rel="noopener">VisBug 101</a></li> </ul> <h4>Weekly Update</h4> <ul> <li><a target="_blank" href="https://www.smashingmagazine.com/2021/05/smashingconf-conference-platform-hopin/" rel="noopener">The Conference Platform We Use For Our Online Events: Hopin</a> by Amanda Annandale</li> <li><a target="_blank" href="https://www.smashingmagazine.com/2021/05/complete-guide-css-container-queries/" rel="noopener">A Primer On CSS Container Queries</a> by Stephanie Eckles </li> <li><a target="_blank" href="https://www.smashingmagazine.com/2021/05/frustrating-design-patterns-birthday-picker/" rel="noopener">Frustrating Design Patterns That Need Fixing: Birthday Picker</a> by Vitaly Friedman</li> <li><a target="_blank" href="https://www.smashingmagazine.com/2021/05/tree-shaking-reference-guide/" rel="noopener">Tree-Shaking: A Reference Guide</a> by Átila Fassina</li> <li><a target="_blank" href="https://www.smashingmagazine.com/2021/05/core-web-vitals-case-study/" rel="noopener">How We Improved Our Core Web Vitals</a> by Beau Hartshorne</li> </ul> <h3>Transcript</h3> <p>Drew McLellan: He’s a bright, passionate, punk engineer with an adoration for the web, who prefers using his skills for best in class UI and UX, and empowering those around him. He’s worked at small and large companies, and is currently a developer advocate working at Google on Chrome. He’s a member of the CSS working group and the creator of VisBug, a design debugging tool. So we know he knows his way around design and UX, but did you know he owns more pairs of flip flops than any living biped? My smashing friends, please welcome Adam Argyle.</p> <p>Adam Argyle: Hello.</p> <p>Drew: Hi Adam, how are you?</p> <p>Adam: Oh, I am smashing, you know it.</p> <p>Drew: That’s good to hear. So I wanted to talk to you today about your project, VisBug, and generally, about the concept behind design debugging and how it might fit into project workflows. I mean, we’ve had developer focused browser debugging tools for a long time, I mean, probably more than a decade now. But those are obviously very much focused on code. So what is different about VisBug? And what’s the sort of problem that it’s trying to solve?</p> <p>Adam: Awesome. Yeah, the main problem that it’s rooted in is, as a front-end engineer I work with designers all the time, and I always loved this moment where we sat down and I’d be like, “Okay. I’m making the final touches. We’ve got another day or two until we deploy. So designer, sit down, and would you critique this? I want you to open up my local host version on your browser and on your phone, or whatever, and talk to me about what you see.”</p> <p>Adam: And after doing this for many years and always loving this interaction, I kind of started to feel guilty after a while because of how common and simple the tasks were. They’d be like, “One pixel down here. Five pixels margin here.” And it was always nits and nudges, and nits and nudges to spacing and type. I mean, rarely was it like, “Ooh, hold on minute while I spend 30 minutes changing some angular, or whatever, to adjust my DOM so that the DOM can support your request,” or whatever.</p> <p>Adam: It was usually tiny stuff. And then I ended up making a survey, and I surveyed all these designers at Google. And I was like, “When you open up DevTools, what do you do?” And it kind of was resounding that they just need basics. And so it was born out of, I was like, “This should be easier. You shouldn’t have to pop the hood on the Ferrari, move a chunk of engine, just to change the color of the car seats. That’s not fair. You should just be able to touch the car’s seats and change the color, just like a design tool.” I was like, “Something could facilitate this workflow.” And I was like, “Okay, I guess I’ll hack on something to see if I can create the solution.”</p> <p>Adam: And that’s how it all started. It really started with spacing and then typography. And once I had a selection mechanism down that emulated design tools it was like, “Well what else can I do?” And it just kept going from there. But yeah, born in that moment.</p> <p>Drew: So the idea is that the client asks you to make the logo bigger, and VisBug helps the browser behave more like a design tool for making those sorts of tweaks. So closer to something like Illustrator, or Photoshop, or Figma, or any of these types of things.</p> <p>Adam: Yeah. That use case is a good one too. Because you could be a with a client and they say, “Oh, we love this,” this is so classic, “we love the design, but that color blue is hard for us.” And you’re like, “Really?” This is like, people can submit a form and you can make money, but you want to talk to me about blue right now? And usually it would create a whole cycle. The PM would go, “Okay, we’ll take down your request and then we’ll send it to design.”</p> <p>Adam: But if the designer’s there and it’s their browser that’s showing it they’d be like, “Okay. Well I’ll just click the thing and change the color.” And you can nip an entire cycle of work by just prototyping the change there in the browser. So it is. It’s most effective against an existing product, right? Because it’s a debugging tool. It’s not necessarily a generation tool. It doesn’t create a site for you. It can, but it’s kind of awkward.</p> <p>Drew: So technically it’s an extension that you install in a Chrome browser. Is that right?</p> <p>Adam: Yep. And it’s an extension. When you launch it it downloads a JavaScript file that says, “Here’s a custom element called VisBug.” And then you put the DOM element, vis-bug on the page. And poof, I just take that moment and turn it into a toolbar, and start to listen to events on the page. I listen to your hover events, and I listen to your click events. And I try to do my best to intercept them, and not compete with your main page.</p> <p>Adam: But yeah, that’s the essence of… The only reason it’s an extension is just so it’s easy to put on your page. Although at this point it does have some settings now that come with you across browsers. But it’s still mostly, 99.9%, a custom element with no dependencies. I think I like a color library I use, and it’s otherwise just all vanilla. Yeah.</p> <p>Drew: I guess that’s how Firebug sort of started out, wasn’t it? As a Firefox extension back in the day.</p> <p>Adam: Yep. That’s why it’s called VisBug. It’s very much inspired by Firebug but for visual designers.</p> <p>Drew: Ah. There we go. I mean, this isn’t perhaps the ideal format, being an audio podcast, to talk about a visual tool. But run us through, if you will, some of the sort of tools and the options that VisBug gives you.</p> <p>Adam: Absolutely. So one of the first things that VisBug does, and you can also, if you are at home or at a computer, you can go to visbug.web.app, and try VisBug without the extension, right?</p> <p>Drew: Ah.</p> <p>Adam: It’s a web component, so I’ve loaded up a webpage for you here at visbug.web.app that looks like it’s got a whole bunch of art boards, and then of course, VisBug preloaded. And the goal of this site is to let you play, and explore, and delete. I think the delete key is one of the most satisfying tools to begin with. You’re like, “What can I do to a page?” And you’re like, “Well I can destroy it.”</p> <p>Adam: And I made it so that you can hold delete, it will find the next… Which is pretty difficult on a delete. You delete something and it selects the next sibling. So it’ll select the next sibling forever. If you hold delete until you delete the whole… Anyway, very satisfying. Hit refresh and it all comes back. But the first tool that VisBug ships with, so when you just launch it, is the guides tool. And I used to literally hold up paper to my screen, or I would go get a system extension that would allow me to sort of mark things and create lines.</p> <p>Adam: Because, yeah, alignment becomes very optical at a certain point for a lot of designers, right? They don’t want, necessarily, mathematical alignment, right? This is why typography has optical kerning. It’s not math kerning. This is human kerning. And so the guides tool is rooted in that a lot of nits that happen from a designer are zooming in on stuff, checking alignment. Is the spacing good?</p> <p>Adam: So that’s the second thing that the guides tool does. When you launch it and you just hover on stuff you’ll see the element that you’re hovered on gets a little box around it. And then dashed guides show up, just like rulers would normally do. And just like in Sketch and Zeplin where you sort of hover and you get these guides, it’s the same concept, just live on your page. And if you click something, and then hover to a new destination, you get measuring tools. And the measuring tools are in pixels, and they’re calculated… So visually, how many pixels are between it. Not what did someone say. It’s not adding up all the spacing, it’s just you click this thing and it’s this far away from that other box.</p> <p>Adam: And I think that becomes really helpful, because you can hold shift and continue clicking, and essentially verify that you have equal spacing between five icons. And it’s just a couple of clicks. Don’t have to know code, just launch VisBug, hover, click, click, click, and you get to see that, “Oh look it is. Yeah. 15 pixels between each of these.” Or sometimes you get something that’s kind of annoying, you’ll click in a box and then click its parent box and you’ll realize that its top distance is nine and the bottom one is eight. And you go, “How will I center this? It is somehow in between.” And shakes fist.</p> <p>Adam: But at least you’re able to see it nice and easily with the guides tool. So yeah, that’s the guides tool.</p> <p>Drew: I’ve definitely been there, with holding up bits of paper to the screen. And also, the other trick that I would use is to open another browser window and use the edge of the window to align items. And then you sort of try and keep everything in the right place so that as you make code change and refresh it’s all still lining up. Yeah, not an ideal way of working, so.</p> <p>Adam: Not an ideal way of working. Yep. And there’s the next… So, oh, and the first version of that was very loose. It didn’t snap, it just held up a crosshair, which is a feature that I’ll add back later. So some users are like, “Hey, I love the snapping, it’s just like my design tools. But what if I want a loose measurement? Or I want to do a letter, I want to measure a letter, not its letter box?” And so, well, this guides tool could very easily be changed to having a modifier key.</p> <p>Adam: So here’s where VisBug gets a little kind of different, but also hopefully familiar, is it’s very heavy on hotkey modifiers. So just like if you watch a pro designer, they’re very much hotkey savvy. And they’re hitting hotkeys here, zooming in, hitting hotkeys over there, and just doing all their nudging from their keyboard. And so VisBug is very keyboard-centric in the way that you change things.</p> <p>Adam: It’s also because VisBug allows multiple selections, and it can change 100 items’ spacing at the same time. And it does so relatively. So anyway, it has a couple interesting quirks, but the keyboard in a modifier concept is really important. And you can hold option, or shift, or command in a lot of the tools and get something different, or get a new sort of feature in there.</p> <p>Drew: So it’s one of those tools where it really pays to learn the keyboard shortcuts.</p> <p>Adam: It does. And so when you launch VisBug and you hover over one of the tool icons, you’ll get a breakdown. It throws out a little flyout menu, it says the hotkey for choosing this tool, and it tells you what it can do, and what interactions to do in order to get them. So the guides tool says, “Element guides, just hover. Measure something, click, and then hover something new. Sticky measurements are shift plus click so they’ll persist.”</p> <p>Adam: And these guides are really nice too for screenshotting. So if you’re reviewing a PR, even as just a front-end engineer, or maybe a designer reviewing a PR, this can be a really powerful way for you to get in there and, yeah, have some high fidelity inspection. Which kind of leads us into the next tool. Do you want to hear about the next tool?</p> <p>Drew: Yeah, sure. Let’s go for it.</p> <p>Adam: Awesome. The next one is the inspect tool. And this one is like… Designers usually, they don’t want all of the CSS, right? When they expect with… I almost said Firebug, but the Chrome DevTools, you get the full list, right? I selected this H1 and so here’s everything all the way back to the browser style sheet. And the designer’s like, “The browser what? The browser has a style sheet?”</p> <p>Drew: Down at the murky bottom of that scrolling panel.</p> <p>Adam: The murky bottom, right?</p> <p>Drew: Yeah.</p> <p>Adam: It’s like you peeled back all the layers and then you’re like, “Ooh, I don’t like these layers anymore.” And the inspect tool here, it says, “Ah, designers, I know what you want. It’s just the border color.” Basically, only show me something if it’s unique, so don’t just cover me with CSS properties. And I’m really mostly interested in color, typography, and spacing. So I’m going to look at margins, line heights, font family’s really important, right? There’s a whole extension just to tell you what the font family is on a page.</p> <p>Adam: In VisBug that’s just a line item in the inspect tool. So you just launch VisBug, hit inspect, and hover on any typography and it’ll tell you the font family. So yeah, it tries to make a designer focused in what it surfaces, yeah.</p> <p>Drew: So that tool is not showing any inherited styles. Is that right?</p> <p>Adam: That is correct. Unless they are inherited and unique. So if they… A text color or something, if the text color isn’t literally the word inherit, it will tell you that it’s a computed value, that it’s something interesting.</p> <p>Drew: Yeah, that’s a really useful just… Yes. Helps you focus on the things that are just literally applying to that one instance of something, which is obviously what you wanted to change. I mean, I guess this could be really useful, all these tools would be really useful in, sort of as you mentioned, getting stakeholder feedback. And sort of working interactively with a client.</p> <p>Drew: I guess it would work equally well over screen sharing, as we have to do these days, more and more. You don’t have to be sat at a computer with someone, you could be sat on the other end of a call and share your browser and do it that way. I guess it’d be quite an effective way of getting feedback when a client can’t point at the screen and say-</p> <p>Adam: Definitely.</p> <p>Adam: It’s always magical when you turn the live webpage into what looks like a Zeplin artboard. Someone’s like, “What… Did we just go somewhere new?” And you’re like, “No, this is your product. We’re just interacting with it very visually.” Yeah, it can be really nice.</p> <p>Drew: Are there any other interesting use cases that you’ve seen VisBug put to or that have occurred to you might be interesting?</p> <p>Adam: Yeah. So, yeah, there’s so many it’s kind of hard to start. Oh, one that’s important is developer to developer communication. VisBug works on the calculated values. So it doesn’t look at your authored values. And that can be really nice, because you’re sort of measuring and inspecting the absolute end result into the way that the pixels got calculated on the screen. And that can be really nice, to have a conversation that way, as you’re working on the results, as opposed to the authoring side.</p> <p>Adam: And you can go back towards like, “Okay, well how did we go wrong in the authoring side if this is what we got visually?” Which also kind of plays into, the next tool is the accessibility inspect tool. So the inspect tool makes it easy just to see the styles on an element, and it breaks them down in a very designer-friendly way. The accessibility tool helps you inspect all of the elements on a page, and it surfaces any accessible properties it has, which makes it, I’m hoping, easier to go verify that something is done.</p> <p>Adam: So a PR… And things often get created. So this is, again, developer to developer, designer developer, you’re reviewing interfaces. It’s just so critical. If you’re looking at an interface and you’re curious, VisBug has a use case for you there. There’s also use cases where you can sort of prototype in the browser. So we talked about one where it’s like, the client wanted to try blue. Okay, that’s a pretty easy scenario.</p> <p>Adam: But there’s other ones too. If you hit command D on VisBug you’ll duplicate an element. And it doesn’t care what you’re duplicating. So you could duplicate a header, go add some spacing between the two headers, and go make a variant live in the browser. You double click the header text and it becomes an editable text field, and you go try a new headline out and go see how the headline fits. Go adjust some spacing and you just saved yourself all this developer work, finding a source file and all that sort of stuff, and you’re just…</p> <p>Adam: So yeah, it can help you explore and verify. It’s kind of a weird… I mean, it’s a lot of the things DevTools does, right? It comes in after you’re done, it doesn’t actually give you source code very often, it’s not very often that you copy code out of DevTools. You might copy a key value pair. Like, “Oh, I changed this style.” But yeah, anyway.</p> <p>Drew: Mm-hmm (affirmative). Yeah. I can think of sort of particularly visual cases where you might want to, you mentioned, duplicating items. You might want to take a whole section of the page and duplicate it to simulate what it would be like if there was a lot more content than you were expecting.</p> <p>Adam: Yes. That’s the chaos testing use case.</p> <p>Drew: Yeah.</p> <p>Adam: Absolutely.</p> <p>Drew: Which is something that we all have to deal with, designing with sort of CMS-based systems and all those sorts of fun tasks.</p> <p>Adam: Yep, that’s a really crucial use case too. Because I do that one for… Yeah, headlines, like I said. You just double click some text and I just go slam the keyboard. Blah, blah, blah, blah, and hit a bunch of spaces, blah, blah. And I’m like, “Okay, how’d the layout do? Oh, it did good. Okay, good, I can move on to the next thing. What happens if I duplicate this four times? Is there still space between everything? Does it flow next to the next item?”</p> <p>Adam: It can be really nice for that simulation of the, yeah, content chaos. Really short title, really long titles, has no friends, has a million friends. How do you handle these use cases in the UI? Yep.</p> <p>Drew: So it works with any browser-based content. So PWAs as well as regular webpages?</p> <p>Adam: Yes, it does. So if you have Spotify installed, I do this all the time, I’ve got Spotify installed and I’ll just be like, “Spotify, you look like you’re an impossible app to inspect.” But guess what? VisBug don’t care. VisBug overlays all your stuff, inspects all the typography. I made a light theme for… Oh, I have a tweet somewhere where I made a light theme of Spotify.</p> <p>Adam: Oh, this was another use case, sorry, for prototyping color. I can create a light theme on the product itself without having to go mess with a bunch of sticker sheets, right? So there’s this important even mentality, I’d love VisBug to help folks get into which is, use your product as a playground. Use that as… It’s so real. It’s more real than your design comps are. So spend some more time in there. I think you’ll find that you can make more effective design decisions working on your actual product.</p> <p>Drew: And the case of accessibility as well is particularly interesting, because often, particularly these days, we’re working very much in component libraries, and looking at small components of a page. And spending less time looking at all those integrated together to create the sort of views that a customer actually interacts with. And it gets really difficult to keep an eye on those sort of finer details like accessibility things, attributes, that aren’t visible on the page.</p> <p>Drew: It’s very difficult to keep an eye on things that aren’t visible. So this is where tooling can really, really help to be able to inspect something and see that, yes, it’s got the correct roles on it and it’s-</p> <p>Adam: It does. That’s the exact use case. I want a PM to be able to go verify this stuff. I want a designer to be able to go look at accessibility and not have to pop open the tools, find the DOM node, it’s all crunched up in the elements panel and looking weird. That it just says, “Here’s the area attributes, here’s the title if it exists.” There’s also some other accessibility tools to. VisBug ships with the search icon. The search icon has multiple ways to interact with it.</p> <p>Adam: So first it queries the page. So if you know the element type or the element class name that you want you can just search it, so you don’t have to find it with the mouse. But that also has slash commands in it. So there’s plugins in VisBug, and they’ll execute scripts on the page. So if you’ve ever had a bookmark that you’ve saved three or four… You’re like, “I’m going to use this one because it highlights all the borders and shows me my boxes.” It’s like a debug trick or something.</p> <p>Adam: It’s probably a VisBug plugin. So you launch VisBug, hit slash, and you’ll get autocomplete, and it’ll show you all the different plugins. And there’s some accessibility ones that are really nice that overlay errors, and various things like that. So I agree. Accessibility should be more accessible. That’s just lame to say. But it needs to be closer to the tool belt. And I think sometimes it’s too far away, and maybe that’s why it gets missed. So I’m hoping if it’s a little more up front, and center, and easier that it gets checked more. Yeah.</p> <p>Drew: And it’s interesting you say that VisBug works with the sort of computed values of things, so like colors. So does that mean that if you have several layered elements that have different levels of opacity that you’d be able to measure the exact color that is being rendered on the screen rather than-</p> <p>Adam: Ooh.</p> <p>Drew: … looking at the individual elements and trying to somehow work it out?</p> <p>Adam: That’s a really good question. So I think, if I’m understanding the question right, which this is a classic difficulty in the front-end is, yeah, how do you know if you have a half opaque text word, what is its color over gray versus over white? And how do you know its contrast? Right now, we don’t know. So VisBug knows the color, and it’ll say, “50% gray,” or whatever the color is that you have there. But it doesn’t know anything smarter than that. It’s not able to…</p> <p>Adam: I think what you’d have to do in that case is create a canvas, paint all the layers on there, and then use an eyedropper or a… So you’d render it in canvas, make them all smashed together into a single painted layer, and then go pluck the single pixel value out to see what its actual end computed gray is after it’s been layered on the other stuff.</p> <p>Adam: I think someone specced it, or maybe I have it as a GitHub issue that it would be nice. Because VisBug could facilitate this, 100%. VisBug, behind the scenes, I’ve already done with text metrics, where you hover on things and it gives you crazy rad information about the fonts. It’s almost too much info, like x height, and cap height, but it goes even more. And it’s like, “Ooh, I’m kind of turned off at a certain point.” So I have to figure out how to find the signal versus noise there.</p> <p>Adam: But yeah, I like this thought process, because we should have a tool that does that. And if we know how to compute it, we can teach VisBug to do it, and that would be a really cool feature to have, opacity relevant calculated color. Love it.</p> <p>Drew: Yeah, I mean, it’s the sort of standard case of having text against a background where you’re not sure if the contrast is enough to pass the accessibility requirements. And perhaps it’s not, perhaps it’s too low contrast and you want to then tweak the values until you get it just to the point where the contrast is good, but it’s not drifted too far away from what the client initially wanted in terms of brand colors and things.</p> <p>Adam: I call that bump, bump until you pass.</p> <p>Drew: Yeah.</p> <p>Adam: Because that’s what it feels like. I’m like, “Ooh, I’m a little short on the score.” So it’s like, I’ll go to my HSL lightness and I’ll just bump, bump, bump, and watch the little numbers tick up until it’s like, “Ding,” I got a green check mark. I’m like, “Okay, cool.” And yeah, sometimes, some of that color is not cool. So, have you studied much of the 3.0 perceptual accessibility work that’s going on? So that we’ll no longer have AA or AAA, we’ll have on number and it includes things like font thinness. So if it’s a thin font it will get a lower score, if it’s a thick font it goes… Because there’s a lot that goes into contrast.</p> <p>Drew: Yeah, no, I hadn’t seen any of that, but that sounds-</p> <p>Adam: Anyway, it’s a really cool thing to explore.</p> <p>Drew: That sounds fascinating, yes. I’ll have to find someone to talk to about that. That’s another episode. So, I mean, I’m sure some developers might argue that everything that VisBug is doing you can just do through the CSS panel in DevTools. And I think that’s sort of fair but probably misses the point, in that, yes, you are manipulating CSS when you’re making changes, but it’s putting a sort of designer-focused user interface on top rather than a developer-focused interface. Is that a fair characterization of it?</p> <p>Adam: That’s a really fair one. And honestly, the best ideas graduate out of VisBug into DevTools. And they already have. So VisBug, if you hit command option C on any element it takes every computed style, at least that’s unique. Again, so it’s like, we’ll do ones that we’re not just going to give you all these inherited properties. But puts them all on your clipboard, and you can go paste that style somewhere else, in a style sheet, in a CodePen, and literally recreate the element in a couple clicks.</p> <p>Adam: And those sort of interactions have made their way into DevTools, into that elements panel. There’s other things, though, that haven’t, which is, the DevTools is a single node inspection only tool. And VisBug follows the design tool mantra which is, no, I should be able to multiselect. I need to be able to bulk edit, bulk inspect. And so I use VisBug all the time for spacing. Because I can highlight multiple elements and see margin collapsing.</p> <p>Adam: In DevTools you can’t ever see it, because you can only see one node at a time most of the time, although there’s way to show multiple margins, but it’s not the same. And so, yeah, it has these niche use cases that can be really fun like that. Another one is, if you highlight a… Let’s say you have a typography system and you have H1 through H7, like in a storybook or something like that, you can highlight all of them in VisBug, hold shift, just click all of them. Boop, boop, boop, boop, go to the typography tool and hit up or down, and it makes a relative change to each of them.</p> <p>Adam: So each of them will nudge up one or down one. And that’s just not something that DevTools makes very easy. And so, yeah, it has some superpowers like that, because it’s a little more agnostic. And it’s prepared to always iterate on an array. Yeah.</p> <p>Drew: So what was the origin of VisBug? And now is it just a personal project? Or is it a Google project? Or what’s the status of it?</p> <p>Adam: Yeah. So first, status is, it is a Google project. Its primary goal is to be a place to prototype and explore before things go into DevTools. At least from the Google side of things. But from my personal side of things I still see it as a place to go bake in the common tasks, or to bake in some optimizations to get through common tasks. And just to give a wider audience a way to look into the DOM.</p> <p>Adam: I really think that the DevTools is super powerful, but it’s very intimidating. Just one tab in it can take a career to learn. I’m still learning things in DevTools, and I use them all the time. And so yeah, this is kind of a different audience in some ways. It’s more of the beginners, the folks coming in, or maybe even folks like PMs, managers, that don’t ever intend to code but are interested in the output. And so it kind of gives them, yeah, just light tooling to get into there.</p> <p>Drew: It’s an interesting point you bring up, because I personally often find that I struggle to find a comfortable workflow in managing all these sort of DevTools. And you’ve got all these little claustrophobic panels, and you can detach them into another window, but then you’re having to keep track of two different windows. And once you’ve got a few browser windows open you can’t… You focus one and you don’t know which DevTools belongs to it.</p> <p>Drew: And then within the panels themselves, it’s kind of a sort of a bit of a Wild West of user interface conventions. You’ll scroll and things’ll start doing strange things that you didn’t expect. And in terms of user experience I feel like it’s all just a big mess.</p> <p>Adam: It is. Yeah.</p> <p>Drew: Do you think that’s unavoidable? Can it be better?</p> <p>Adam: I definitely have thoughts here. And yeah, I think a good… So let’s say you have a listener right now that’s like, “I’m pretty savvy with the DevTools. I don’t think they’re that crazy.” I’d say, “Okay, go open up Android Studio or Xcode. Begin a project, and go look at the DevTools, go look at the output. How familiar do you feel right now?” Probably very foreign. You’re looking at that going, “This is garbage. Why do they do this? Why is this panel over here?” And your mind starts to race with all these questions why and confusion.</p> <p>Adam: And it’s like, well that’s how everyone feels the first time they open DevTools. So you got to really kind of be empathetic to that.</p> <p>Drew: Is it inevitable that… Can we do better? Or is this just the sort of natural order of things?</p> <p>Adam: So here’s my current take on this, is I think complexity is really easy to find yourself getting into. And DevTools is one of those things, they’re just naturally complex. There’s no good UI to facilitate a lot of these things. A lot of these things get built by devs. And I think devs building tools for devs is fine, because you’re going to have… If it’s the only way, or if it’s even if it’s a good way, you’re going to learn it, and you’ll get good at it, and you’ll get comfy with it.</p> <p>Adam: And all DevTools are kind of weird, because they’re made for their weird use cases, right? Development is weird. Let’s just be honest. We make invisible cogs and invisible two by fours, and we build houses, basically, with invisible, virtual parts. So yeah, we need weird tools to go inspect these things, and to tell us what they’re outputting.</p> <p>Adam: Now, that being said, what VisBug does, and what I’ve been kind of slowly moving things into DevTools as, is smaller tools that are more focused as opposed to a big tool that claims to do a lot. I think it’s hard for things to do a lot really well. And this is classic argument, right? This is all stars, specialists versus generalists. Neither are always going to be perfect.</p> <p>Adam: But what VisBug is trying to do is, it has made specialists. So the guides tool just does guides. And that tool never leak into the other tools of the page. And so I’m trying to do that more with DevTools, where DevTools wants to help designers more, which is something VisBug has helped inspire DevTools to see. And the way that I keep introducing things is, instead of making a grid editor, for example, where you can… “Full power of grid in one overlay,” right? “You can add tracks, remove tracks, blah, blah, blah.”</p> <p>Adam: And I’m like, “That sounds really cool and also really complex.” I’m like, “Grid is crazy, there’s no way we’re going to build a GUI for that.” So I’m like, “Why don’t we just handle grid template columns first, and the ability to manage the tracks in there, almost like they’re chips? What if we could just add, and edit, and delete them?” They’re much more physical and less of string. I’m like, “Well what we’ve done is, we’ve created a micro-experience that solves one problem really well and then doesn’t leak anywhere else, and it’s also really naïve. It’s a naïve tool.”</p> <p>Adam: So and a good example of that is the angel tool in DevTools. Have you seen that tool yet?</p> <p>Drew: No, I haven’t.</p> <p>Adam: Any angle… So this is, I’m calling these type components. So their CSS is typed, and the angle is a type, and many CSS properties will take a type value of angle. And what I was like… Well, angles, those are just a wheel like a clock. Why don’t we give someone a GUI so that if they click an angle they can change an angle and snap it to 45, snap it to 90, there’s common interactions with just this unit of angle.</p> <p>Adam: And we made a tool for it. And it’s super cool. It looks great, the interaction is great, keyboard accessible the whole nine, and that’s an example where I think you can make small focused things that have big impact, but don’t necessarily solve some big problem. And yeah, you’ll have another tool like Webflow that’s trying to create entire design tool and facilitate all your CSS.</p> <p>Adam: So, yeah, I don’t know the right answer, but I do know that an approachability factor comes in when things do less. And so it just kind of makes it a little easier. Like VisBug, you might only know three tools on it. You only use the guides, the margin tool, and then the accessibility inspect tool. Maybe you never use the move tool or the opposition tool. Just, yeah.</p> <p>Drew: I mean, talking of design tools, we’ve seen a big rise in the last few years of tools. Things like Figma, which are great for originating new design work in the browser. Is there overlap there with what Figma is doing and what VisBug is trying to do?</p> <p>Adam: There’s definitely overlap. I think they come at it from different directions. One of the things that I’m frustrated with Figma at is not something that VisBug could solve. And I think that design these days, even with the powerful tools and the Flexbox-like layouts that we have, I still think we start wrong when we draw a box on a canvas of a certain size. I’m like, “Sorry, that’s just not the web. You’re already not webby.”</p> <p>Adam: Nothing is very content-focused. If I just drop a paragraph into Figma, it gives it some default styles and I’m like, “Why doesn’t it do what the web does? Put it in one big long line.” You’re like, “Contain it somehow,” right? And so I don’t know. I think that Figma is empowering people to be expressive, limitless… What is the phrase I like to use? Yeah, okay, it’s expression-centric. That’s where I think VisBug and a lot of debug tooling is…</p> <p>Adam: So yeah, one is empowering expression, and the other one is empowering inspection and augmentation. You need both, I think. I think that in one cycle of a product you’re in full expression. You need to not have any limiters. You need it to feel free, create something exciting, something unique. But then as your product evolves and as more teammates get added, and just the thing grows and solidifies, you’ll exit a phase of expression and into a phase of maintenance, and augmentation, and editing.</p> <p>Adam: At which point your Figma files do two things, they get crusty, because your product is more… Well, it’s real. Your product has made changes, and design decisions, because it’s now in the medium. And so your file starts to look crusty. And then your file also just is constantly chasing production. And that’s just a pain in the butt. And so VisBug is sort of waiting. So in the expression phase VisBug’s like, “I can’t help you very much. I’m just sort of, I’m not that powerful at expression.”</p> <p>Adam: But then as you have a real product you can inspect it. And yeah, it can inspect anything. It has no limits. It goes into shadow DOM and everything. So yeah, I think they’re just different mentalities for different phases of products, yeah.</p> <p>Drew: So in VisBug if you have made a whole lot of changes, maybe you’re sat with a client and you’ve tweaked some spacing, and you’ve changed some colors, and you’ve got it looking exactly how the client wants, they’re happy. They obviously now think that all the work has been done.</p> <p>Adam: It’s done.</p> <p>Drew: Which of course, it’s not. We understand that. But what is the path? What is the developer journey from that point to… I mean, I presume that it’s not practical to save or export, because there’s no way to map what you’re doing in the browser with those source files that originated that look. But what’s the journey? How do you save, or export, or is it, I guess, taking a screenshot? Or what do you do?</p> <p>Adam: Yeah, there’s a couple paths here. And I want to reflect quickly on what we do in DevTools. So let’s say, DevTools, we made a bunch of changes, there is the changes tab in DevTools, I don’t think very many people know about it, which will surface your source file changes, and some other changes in there that you could go copy paste.</p> <p>Adam: And yeah, this becomes a hard thing with all these tools that are editing code output, they don’t have any knowledge of source or authoring files. I mean, maybe they have source maps, but I think that’s a really interesting future. If we get to something where the calculated output could be mapped all the way back to the uncompiled source, that’d be really cool. But until then, VisBug does do similar to what you do in DevTools. Where you just copy paste the sort of pieces.</p> <p>Adam: But I will share some fun ways to sort of make it even better. So one thing, let’s say you made a header change, color change, and a change over here. You can go to the inspect tool, and when you hover on something it will show you a delta. It’ll say, “Local modifications.” And if you hold shift you can create multiple sticky pinned inspections. And so you’ll go to your header, you’ll click it, you’ll hold shift, click your other little box, and hold shift to click another little box. And now you have tool tips showing what you changed over the actual items in the page, take a screenshot, and ship it to a dev.</p> <p>Adam: And they can sort of say, “Okay, I see you changed margin top to 20 pixels. I don’t use pixels or margin top in my CSS. So I’ll go ahead and change to margin block start two RAM, thank you and bye bye.” And that’s kind of nice, is that the editor didn’t have to care or know about the system details, they just got to say something visually and screenshot it. So that workflow is nice. It’s pretty hands off and creates a static asset which is fine for a lot of changes.</p> <p>Adam: But if you had a lot of changes and you really changed the page and you wanted to save it, there is another extension called… Let’s see. Page, single file. Single file will download the entire current page as a single file HTML element, at which point you could drag that right into Netlify and get yourself a hosted version of your prototype.</p> <p>Adam: Because what VisBug does is, it writes its styles in line on the DOM notes themself. So save file comes with it all. And I’ve got a tweet where I went to GitHub and I made… I just totally tweaked the whole site, and it looked cool. And I was like, “All right, save file.” And I saved it, opened it up in a new tab, just dragged it into the new tab and I was like, “Well this is really cool.” Because VisBug’s been wanting a feature like this for a while. But it’s a whole other extension’s responsibility, is taking those third party assets, dealing with all the in line… And anyway, so it’s really nice that that exists.</p> <p>Adam: And so you can deliver a file, if you want to, or host it somewhere, and share multiple links to multiple versions of production. You modified production and then shipped it into netlify, and someone can go inspect it, and it’s still responsive at that point too, right? At that point it’s not a static comp you’re sharing, it’s still the live, responsive… Anyway, it’s exciting. I mean, there’s a future here that’s, I think, really, really interesting and not far away.</p> <p>Adam: It’s just like we’re a little still stuck, as designers, in our expression land. We’re just too happy expressing. And we’re dipping our toes into design systems, but even those I think are starting to get a little heavy for designers. And they’re like, “Ooh, maybe it’s too much system now.” And like, “Ugh, I’m getting turned off. I liked making pretty stuff. And it’s a whole new job if you’re doing design ops,” or whatever. So…</p> <p>Drew: I like the fact that VisBug takes an approach of not being another DevTools panel, because the interface, it embeds a toolbar on top of your page just like a design toolbar. I guess that was a deliberate move to make it more familiar to people who are familiar with design tools.</p> <p>Adam: Yep. If you’ve used Paint or Photoshop, they all come that way. And so it was the sort universal thing, that if I put a toolbar on the left that floated over your content, almost everyone’s going to be like, “Well I’ll go hover on these and see what my options are. And here’s my tools. And I get to go play.” And it made a really nice, seamless interaction there. I do have a really exciting almost finished enhancement to this.</p> <p>Adam: So, it’s so cool to me, but I don’t know if everyone else is going to be as excited. And this’ll be a mode that you can change in your extension settings, is how do you want to overlay the page? Because right now VisBug puts a toolbar right on the browser page, which the page is rendered normal, and I know this is going to be weird to say that, but okay, so you scroll the page, and the content, and the body is width to width in the browser, right? So it’s filling the little viewport.</p> <p>Adam: I have a mod where, when you launch VisBug it takes the whole HTML document and shrinks it into an artboard. It looks like an artboard. It’s floating on a shadow on a gray space. You can infinitely pan around it. So you can scroll away from your page canvas, and what it lets you do is, see, let’s say you have a page that’s really long, and you want to measure something from the top to the bottom, well you can do that right now, but you’d kind of lose context as you go.</p> <p>Adam: Well in this new VisBug zoom scenario, you hold option or alt on your keyboard, you use the mouse wheel, or you hit plus minus with your command and you can zoom your webpage as if it’s an artboard. And I try to make it as seamless as it is. So you’re going in and out, and you scroll down, you go in and out, measure from the… And VisBug just doesn’t care. It keeps drawing computed overlays, you can change spacing.</p> <p>Adam: Because I think it’s really important, as a designer to see the bird’s eye of your page live. Animations are still playing, y’all. Scrollable areas are still scrollable, right? It’s really cool. You’re like, “My whole page in one view.” Anyway, so it’s almost done. It’s in-</p> <p>Drew: Sounds trippy.</p> <p>Adam: It’s very trippy. And it’s in, I just need to make sure it works cross browser, because it’s doing some, obviously, some tricky things to make your live page feel that way. But yeah.</p> <p>Drew: Amazing. Is it… I mean, I presume that VisBug is fairly regularly updated and is being progressed. What is it that we might expect to see in the future?</p> <p>Adam: Yep, that’s definitely one of the features I’m working on there. I have a feature where… So, when you click something you get an overlay with what looks like handles, right? And it’s sort of an illusion, it’s supposed to make you feel comfortable. And the intent is to eventually have those handles be draggable. But I have some fundamental things I have to solve first, like elements in the browser don’t have a width. So if you just start grabbing the width I have to do work to make that illusion feel right.</p> <p>Adam: And you might not even get the results you want, because it could be a block level element that you’re pulling the width smaller, and you’re not getting reflow of an item next to it. And you might be wondering why. So I have prototypes where you can drag corners, drag elements around. But I really need to focus on how the design tools are doing this. They always have this toggle button. And it’s like… See, what’s the toggle called?</p> <p>Adam: But it’s basically like shrink… I call it shrink wrap. Shrink wrap my element, it’s the width of this element is the width of its content, versus here’s the width of my element, stick something in it. So I need something like that in the browser, overlayed on the element so that you could choose between these and maybe even something that let’s you choose between block and inline, so that you could get the results that you want.</p> <p>Adam: But ultimately the goal here is that VisBug does not want to be entirely keyboard-driven. I want you to be able to drag spacing. If you see 12 margin spacing on top, you should be able to reach in and grab it, whereas right now you have to hit up on the keyboard to specify the top side of the box needs an addition of margin.</p> <p>Adam: And so yeah, I have a couple of quirks to work out, in terms of strategy. But it’s very much a goal to make it even closer to design tools. And maybe even I will bend in that. It’s like, well, if you want to change the width and you’re going to get a weird design, there’s always ways to get out of it with VisBug, like the position tool really lets you escape the flow. So flow is ruining your idea, the position tool lets you escape.</p> <p>Adam: And so there’s… If someone was to get really savvy with VisBug they would blow people’s minds, because it’s sort of unlimited, and it’s like, what can you bring to the table? It has an expression element to it. There is definitely expressive tactics. But anyway, so long story short is, the illusion is, I just want to make it smaller and smaller and smaller. I want the illusion to just be like, “Wow, I’m really feeling like a design tool.”</p> <p>Adam: And then, yeah, some enhancements to exporting would be nice. But also, enhancement to exporting for DevTools would be nice, and that doesn’t really stop us. So I don’t know. There’s a ton of issues, definitely go vote on them. I think one of the next big features I’d love to do is green lines. So instead of just showing accessibility overlays on hover to really indicate some things with green lines, and expose more, and surface more information, and I don’t know. Yeah.</p> <p>Drew: Sort of thinking about the process of building a Chrome extension like this, I mean, presuming it’s all implemented in JavaScript, how much like regular web development is it? Building a Chrome extension.</p> <p>Adam: That’s good question. It’s… Phew, this is hard one. It’s quirky. First off, the environment that you get to launch your code in isn’t the browser. They don’t really give you full access there. You can, if you really get tricky with it, which VisBug had to graduate into, this even trickier scenario. So right now, I used to execute in the… This is going to get so fuzzy so fast.</p> <p>Adam: Because there’s multiple sandboxes for your extension, for privacy issues. And they make it hard to execute scripts on the actual page, right? Because you don’t want someone submitting your form when you launch the thing or something, submitting it to themselves or whatever. It could be really destructive. So it has some quirks like that. There’s a bridge you have to pass over. And one of them that’s been plaguing VisBug is, VisBug used to use…</p> <p>Adam: So it’s all custom elements, and custom elements allow you to pass rich data to them as property. So you’re saying like, customelement.foo=myrichobject, full of arrays or whatever. And the custom element just gets that as some data on the node itself. But since I’m in this weird little sandbox world, if I try to set something unique like that on my object, essentially it’s filtered out. They’ve established that certain things can’t… So I can pass a string to my custom element, but I can’t pass it a rich object.</p> <p>Adam: But yeah, other than little quirks like that, once you get the flow down, and if you spend the time to get a rollup scenario, which is going to be an hour or so of work so that you give LiveReload in your thing, it can become pretty natural. I think Firefox has, honestly, the best extension development experience if you’re savvy with the CLI you can spin something up with one command, and it installs it, gives you these LiveReload features, and gives you debugging tools. It kind of holds your hand through it, it can be really nice.</p> <p>Adam: But ultimately, it’s a little quirky. That’s why I do a lot of the work on that demo site that looks like a bunch of artboards, because I don’t really need a real webpage most of the time, to do VisBug testing, as long as I’ve got artboards that simulate various issues, or have accessible things to look at, and sort of give me the content I need to see. I do a lot of the work right there in the browser as if it’s just a normal web application. So VisBug’s dev experience is really easy, unless you’re trying to test it across browser, and then it just gets kind of messy and whatever.</p> <p>Drew: That’s really interesting insights. So I’ve been learning all about VisBug today, what have you been learning about lately, Adam?</p> <p>Adam: I am still improving my wok skills. So I want to be a wok man, and I’m not talking the ’90s cassette player. I’m want to flip veggies and have them kind of catch fire a little bit in the air, cover them with some delicious spices, and just really sear up that garlic and make it crispy delicious. And then put it on a little bed of rice and slide it towards you and see what you think.</p> <p>Adam: So I’m excited for summer right now, because that means I get to whip out the wok and get back into that fast-paced, hot cooking environment, and it’s really fun.</p> <p>Drew: Amazing. That sounds delicious. If you, dear listener, would like to hear more from Adam you can follow him on Twitter where he’s @argyleinc, and find his personal website at nerdy.dev. If you want to give VisBug a try, you can find it in the Chrome Web Store, and you can try out the sandbox version at visbug.web.app. Thanks for joining us today Adam. Did you have any parting words.</p> <p>Adam: No, you were really nice. This was really sweet. Thanks for having me on, I really appreciate it.</p> <div class="fixed"></div> </div> <div class="under"> <span class="categories">Categories: </span><span><a href="http://www.webmastersgallery.com/category/uncategorized/" rel="category tag">Others</a></span> <span class="tags">Tags: </span><span></span> </div> </div> <div class="post" id="post-4078509"> <h2><a class="title" href="http://www.webmastersgallery.com/2021/05/17/ux-design-doesnt-end-with-your-website/" rel="bookmark">UX Design Doesn’t End With Your Website</a></h2> <div class="info"> <span class="date">May 17th, 2021</span> <span class="author"><a href="http://www.webmastersgallery.com/author/admin/" title="Posts by admin" rel="author">admin</a></span> <span class="comments"><a href="http://www.webmastersgallery.com/2021/05/17/ux-design-doesnt-end-with-your-website/#respond">No comments</a></span> <div class="fixed"></div> </div> <div class="content"> <div class="ftpimagefix" style="float:left"><a target="_blank" href="1" rel="noopener"><img decoding="async" src="https://www.webdesignerdepot.com/cdn-origin/uploads/2021/05/featured_uxexpand-scaled.jpg" align="left" alt="" width="100%"></a></div> <p> User experience design is something that most of us associate with websites. But why isn’t it something we extend beyond the website?</p> <p>Here’s why I ask this:</p> <p>As a consumer, it’s so rare that your only interaction with a brand is through its website. Take an ecommerce site, for example. You buy a product from it, and then what happens?</p> <ul class="tight_list"> <li>You get a confirmation email;</li> <li>You get another email when the package ships;</li> <li>You might get another email or SMS notification when the package is delivered;</li> <li>You retrieve the package and open it;</li> <li>You open up your purchase and use it.</li> </ul> <p>These are all an extension of that initial user experience on the site. If there’s just one hiccup along the way, it could easily erode the trust and happiness you felt after quickly finding and buying what you needed on the site.</p> <p>So, what I’d like to do today is look at 10 areas where UX design should extend beyond the website to ensure that the frictionless experience started there remains untarnished.</p> <h1>Extending UX Design Beyond the Website</h1> <p>As a web designer, you might be thinking that this part of the user experience doesn’t fall under the umbrella of your responsibilities. And you may be right about that.</p> <p>For brands to truly be successful and profitable, <em>someone</em> needs to carefully examine the bigger picture and ensure that the user experience is flawless no matter how far away from the site it is. At the very least, you should share the UX research and strategy you do for a client’s site so their team can ensure it carries over to other areas of the business.</p> <p>Here are some things to think about:</p> <h2>1. Mobile App</h2> <p>It’s not uncommon for websites to have mobile app counterparts these days. The layout doesn’t need to be identical since mobile users tend to behave differently than those on desktop.</p> <p>That said, an app shouldn’t force users accustomed to the desktop experience to re-learn how to navigate or engage with the brand. So, the branding, UI design, speed, security, and navigation all need to be on par with what’s already been established in terms of usability.</p> <h2>2. Email</h2> <p>Most websites have a direct connection to email. For example, blog newsletters, purchase confirmation emails, and lead generation follow-ups all start on the website.</p> <p>Consumers are well aware that when they hand over their email address, they will receive an email in return. In many cases, those emails are welcomed when they’re done right. But if something feels off, that bridge could easily burn between brand and consumer.</p> <p>To preserve the UX, emails should come with the following:</p> <ul class="tight_list"> <li>The same branding and visual style as the website;</li> <li>A personalized subject line, greeting, or offer;</li> <li>Consistent messaging as the site, especially when it comes to the CTA.</li> </ul> <p>Another thing to remember is that email isn’t the time to inject dark patterns into the experience. So, the “Unsubscribe” option should be in an easy-to-spot area and a sharply contrasting font color.</p> <h2>3. Social Media</h2> <p>Social media is another channel that’s commonly connected to a website. While you can’t control the aesthetics of social media websites themselves, the visuals and messaging in posts need to be on-brand.</p> <p>That means that things like memes and emojis — which are popular means of communication on social — should only be used if they’re normally part of the brand identity. If not, you’ll need to find other ways to communicate engagingly.</p> <p>Another part of the user experience to think about is customer support. Social media is a lot like going into a store. If someone has an issue with what they bought or the service they received, there will be many people around to witness the complaint. Social media only amplifies that — so the quality of customer care needs to be consistent with how the brand handles it everywhere else.</p> <h2>4. SMS</h2> <p>Not every brand will need to be connected to customers via text messaging. eCommerce companies, news sites, and personal services providers likely will, though.</p> <p>However a brand uses SMS, the same UX guidelines apply here as they do across all other channels:</p> <ul class="tight_list"> <li>Keep messages concise;</li> <li>Make sure they’re relevant and valuable;</li> <li>Use branded messaging and design;</li> <li>Don’t abuse the privilege and send too many;</li> <li>Make it easy to opt out.</li> </ul> <p>Basically, if you can’t make it a valuable extension of the brand’s offering, don’t use it.</p> <h2>5. Phone</h2> <p>Any website that publishes its phone number should expect to receive calls from prospects and customers. While there’s nothing to design here visually, the experience of getting on the phone with a company should be consistent with what they experience elsewhere.</p> <p>One way to do this is to design an easy-to-follow routing system. It should be simple for callers to figure out which number to choose. What’s more, there should be no endless loops. If a caller has exhausted the options, they should be immediately directed to a representative.</p> <p>Another way to ensure consistency is to adhere to a script — that goes for call centers for enterprises as well as the local lawyer’s office. Every caller should be greeted with the same tone and handled in the same manner (depending on the situation, of course).</p> <h2>6. Ads</h2> <p>There are a lot of places where brands can advertise these days:</p> <ul class="tight_list"> <li>Google search;</li> <li>Social media;</li> <li>Ad networks;</li> <li>TV;</li> <li>Radio;</li> <li>Podcasts;</li> <li>Blogs;</li> <li>Billboards;</li> <li>Direct mail.</li> </ul> <p>When designing an ad campaign, there should be consistent messaging, aesthetics (when relevant), and CTAs presented. If branding isn’t consistent from ad to ad, there may be a delay in consumers recognizing the brand or its offer. Or, worse, not recognizing it at all.</p> <h2>7. Packaging</h2> <p>For brands that sell products, you have to think about how the packaging will impact the user experience. There are two types of packages to consider, too.</p> <p>The first is the product’s own packaging. Branding should be clear as day and consistent with the site they bought it from.</p> <p>It should also be easy to open. There’s nothing more frustrating than finally getting your purchase, only to realize you need tools to get it out of the packaging.</p> <p>You also have to think about packaging for products that get shipped.</p> <p>The product should fit well within the packaging. A too-roomy package will feel downright wasteful. So will excessive bubble wrap and paper filler.</p> <p>Having a shipping label present in the package is also important. If the website makes it easy to make a purchase, the package should offer a convenient way to return the product if they’re not happy.</p> <h2>8. Product</h2> <p>The product itself has to align with the expectations set by the website.</p> <p>Take the example of a SaaS. You’ve built an awesome landing page and mobile app store page to promote it. It looks great, it loads fast, and it’s easy to get around. But if the SaaS itself is ugly, disorganized, slow, or otherwise just clunky, all of the work you did to market it will end up being just false advertising.</p> <p>So, make sure the expectations set before and during purchase naturally carry over to the experience with the product.</p> <h2>9. Business Exterior</h2> <p>For brick-and-mortar companies, the business’s exterior matters just as much as what happens inside it.</p> <p>The most obvious thing to focus on is the aesthetics of the building. Does it look attractive? Is it in a safe area? Is there clear signage around it? Is it easy to find?</p> <p>But you also have to think about user experiences that take place outside of the building. For example, there’s now a rise in curbside pickup. There are tons of things that can affect how happy the customer is with the experience — like if the pickup area is hard to find, there are never enough spots or the associates who deliver the orders always seem to be in a foul mood.</p> <p>The business’s exterior should always set a good impression for what takes place inside.</p> <h2>10. Business Interior</h2> <p>Here are some things to think about when it comes to “designing” business interiors for a good UX:</p> <ul class="tight_list"> <li>Decor;</li> <li>Layout;</li> <li>Signage;</li> <li>Furnishings;</li> <li>Product discoverability;</li> <li>Availability (of products or people);</li> <li>Quality of customer service;</li> <li>Checkout process.</li> </ul> <p>It doesn’t matter what the company does — whether it’s a large retailer like Walmart or your own freelance design business. If a business’s establishment doesn’t look good, operate flawlessly, or provide a good person-to-person experience, it’s going to be very hard to get people to return.</p> <p>So, all those things you do to design a streamlined website journey should be applied to a bricks-and-mortar business’s interior.</p> <h1>Wrapping Up</h1> <p>Depending on the types of companies you build sites for, some of the channels and suggestions above might not be relevant. Hopefully, this has got you thinking about other ways you (and your clients) can extend the UX design and strategy from the website.</p> <p>If you can maintain the high-quality user experience from channel to channel, your clients’ brands will get more business, grow their profitability, and see a rise in loyalty, too.</p> <p> </p> <p><em>Featured image <a target="_blank" href="https://www.pexels.com/@olly?utm_content=attributionCopyText&utm_medium=referral&utm_source=pexels" class="broken_link" rel="noopener">via Pexels</a>.</em></p> <p><a target="_blank" href="https://www.webdesignerdepot.com/2021/05/ux-design-doesnt-end-with-your-website/" rel="noopener">Source</a></p> <p>The post <a target="_blank" href="https://www.webdesignerdepot.com/2021/05/ux-design-doesnt-end-with-your-website/" rel="noopener">UX Design Doesn’t End With Your Website</a> first appeared on <a target="_blank" href="https://www.webdesignerdepot.com/" rel="noopener">Webdesigner Depot</a>.</p> <div class="fixed"></div> </div> <div class="under"> <span class="categories">Categories: </span><span><a href="http://www.webmastersgallery.com/category/design/" rel="category tag">Designing</a>, <a href="http://www.webmastersgallery.com/category/uncategorized/" rel="category tag">Others</a></span> <span class="tags">Tags: </span><span></span> </div> </div> <div class="post" id="post-4078398"> <h2><a class="title" href="http://www.webmastersgallery.com/2021/05/17/a-love-letter-to-html-css/" rel="bookmark">A Love Letter to HTML & CSS</a></h2> <div class="info"> <span class="date">May 17th, 2021</span> <span class="author"><a href="http://www.webmastersgallery.com/author/admin/" title="Posts by admin" rel="author">admin</a></span> <span class="comments"><a href="http://www.webmastersgallery.com/2021/05/17/a-love-letter-to-html-css/#respond">No comments</a></span> <div class="fixed"></div> </div> <div class="content"> <p><a target="_blank" href="https://css-tricks.com/author/likeapenguininthedark/" rel="noopener">Ashley Kolodziej</a> — May 2021</p> <h1>Dear HTML & CSS</h1> <p>I see you.</p> <p>In the back there, behind JavaScript and React and PHP and all those “real” programming languages, I see you. And I appreciate you.</p> <p>I’ve seen the YouTube videos. You’ve been condensed down to a sixty-second blip on the path to bigger and better things, a one-trick <code>div</code> pony at the back of the race. You’re a support character. Everyone knows HTML these days. Even if that’s not the case, it’s not hard to learn, they say.</p> <p>I know it’s not true.</p> <p>You are the foundation of the Internet. You are the bridge between humans and information. When we say HTML isn’t an expertise in and of itself, when we take you for granted, we leave behind the people and systems who access that information using web crawlers and accessibility technology.</p> <p>They say you’re not a real programming language like the others, that you’re just markup, and technically speaking, I suppose that’s right. Technically speaking, JavaScript and PHP are scripting languages. I remember when it wasn’t cool to know JavaScript, when it wasn’t a “real” language too. Sometimes, I feel like these distinctions are meaningless, like we built a vocabulary to hold you (and by extension, ourselves as developers) back. You, as a markup language, have your own unique value and strengths. Knowing how to work with you best is a true expertise, one that is too often overlooked.</p> <p>Markup requires systematic thinking. What structure is the best match for this content? How can we make this content easier to discover and parse in the right order? What tags do we need to ensure a screen reader will parse your information correctly? I want you to know I know how important you are, and I still ask these questions.</p> <p>I think of you every time I test a website in VoiceOver and discover it is completely unusable, with my keyboard’s focus jumping away to places I can’t actually interact with and no clear sectioning and headings to help navigate.</p> <p>And to my longtime friend, CSS. I want you to know I understand you are so much more than just a pretty face. Sure, your main job is to, well, style markup. But why should that be any less celebrated than the other languages? You are the visual translation of information. What good is all the information in the world if we can’t easily understand it? You hold the keys to hierarchy and contrast and layout, the keys to visual communication.</p> <p>Your language is an art. I recognize your importance, the balance of performance in rendering and specificity and predicting when and where other systems or designers might want to override something. Sure, you style, and you style well. But what the world forgets sometimes is you are, at heart, a planner: the cascading part of Cascading Style Sheets. Oh, to be JavaScript where you can do whatever you want, whenever you want, and change markup and styles on the fly. Don’t they know inline styles are some of the most specific styles around?</p> <p>I know, and I respect that. There is a time and place for specificity, and I cherish your ability to manage that. I love your system of overrides, of thinking ahead to what should and shouldn’t be modifiable by another developer easily. I find the appreciation of specificity and <code>!important</code> and contrast and all the beautiful little things you do well increasingly lost in the pursuit of the newest and shiniest frameworks.</p> <p>But I am still here for you, HTML and CSS. And I will continue to show everyone I can how much you both have to offer. Because without that foundational care and expertise, we wouldn’t be able to communicate this information at all. You are the languages at the core of equitable information distribution, and I want you to know that even if you aren’t in the spotlight right now, I remember that.</p> <p>Even if it sometimes feels I’m the only person out there who still does.</p> <p><title>With love, Ashley Kolodziej


The post A Love Letter to HTML & CSS appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

The Ultimate Guide for Flyer Size and Design

May 17th, 2021 No comments

Although it may sound obsolete, a flyer is still one of the most effective and inexpensive ways to promote a business. They are also very easy to distribute.

So, if you want your flyers to be impactful, you have to make sure you choose the right size, the right font, colors, and message. Depending on your needs, these parameters will change. Let’s see together how you can create the ultimate flyer by choosing the right size and design.

General Tips

Planning an Effective Flyer

Before we get started, though, we should settle a few things. First, you have to decide what you need the flyer for – is it to promote your business, is it a flyer to announce an event, or just for general awareness? Because your overall design and size will depend greatly on this particular piece of information. 

Then, you need to set your budget. Regardless of the reason you need to design a flyer, you have to set your budget, so you can know right from the start what you are dealing with and what options you have available.

Last, but not least, you have to know where and how you are going to distribute these flyers. This is also an important aspect that needs to be taken into consideration if you want to reap the most benefits out of this endeavor. 

Writing tips

There are many things you need to know when creating a flyer, especially when it comes to writing. But I’m going to make a short list of tips that is going to give you a good idea about the most important things you need to keep in mind when writing a flyer.

  1. Brief is always better – whatever you do, make sure you keep your content brief. Learning how to synthesize your information is key when writing flyers; don’t overwhelm your readers with a long block of text – it’s never appealing and your flyer will miss its purpose;
  2. Use bullet points – a short text can be made more appealing if it’s structured. You should aim for balance – succinct text and structured data using bullet points or charts.
  3. Divide your content into sections – if you have ever seen a flyer, you know that less is more when it comes to written content. Try not to overcrowd it with large blocks of text. Instead, separate text into sections, that way you can ensure readability and easy understanding of your message.
  4. Come up with a catchy headline – nothing hooks a reader better than a catchy headline. Having an interesting title will also ensure that your readers will keep on reading your flyer.
  5. Always proofread – I don’t know what you’ve heard before, but bad grammar and spelling are never sexy. Show that you care about readers and even yourself by putting forward only high-quality content that has been proofread before printing.
  6. Include contact info – although you may think it’s funny, many people forget to add this important piece of information to their flyers. Never forget to include your contact information.

Simple and straightforward – two things that you should take into consideration when writing your flyer. Regardless of the information, you want to include, make sure it’s concise, well-written, and readable. Give your readers the chance to find the information quickly, don’t let them get lost in the details.

Ultimate Size Guide for the Perfect Flyer

Ok, so you’ve got your text all planned out. Now it’s time you chose the perfect size for your flyer. As discussed, depending on the reason you want to create this flyer, you will have to decide on the best size it should have. A promotional flyer won’t have the same size as a general awareness flyer. Let’s see together that size fits what purpose.

What Flyer Size Should You Use?

There are a few standard sizes people and businesses use when they create flyers. Here’s a list of the most popular flyer sizes:

  1. A7 – 105mm x 74mm
  2. A6 – 148mm x 105mm
  3. A5 – 210mm x 148mm
  4. A4 – 297mm x 210mm
  5. DL – ? the size of the A4
  6. Square – 140mm x 140mm, 148mm x 148mm, or 210mm x 210mm.

Let’s take it one at a time so you can better understand which flyer size is used for which type of flyer, depending on your marketing needs.

The A7 and A6 are probably the most popular flyer sizes because they’re the smallest and they’re easy to fill out with information. But just because they’re easy to fill out, it doesn’t mean it’s an easy task to create the perfect text. Because the flyer is so small, the information on it should not only be on point, but it should catch the attention of whoever is reading it, and quickly! These flyer sizes are perfect for promotional purposes or announcements, regardless of their type.

For flyers that are intended to provide more information, the A5 is the better choice. Ranking as high as the A7 and the A6 in popularity, the A5 allows you to be more playful with your texts and illustrations. Used for promoting products or services, the A5 is the go-to size for businesses that want to make use of all the marketing strategies available.

The A4 might not be considered a flyer by many, but rather a poster. The standard paper size, the A4 is also used for flyers, but it’s less popular. The reason is evident, the paper is too big and it’s hard to hand out. Most companies wouldn’t even go for A4, let alone past it, into A3 territory (which is definitely a POSTER!). Make sure you have enough information to add to an A4. Don’t just use it because it’s convenient or easy to find. It’s safer and better to use a smaller size of paper when creating a flyer. 

The DL fits perfectly into an envelope and this is what makes it the perfect flyer size. Whether you want to use it for a mail campaign or just to hand out, the DL fits in every pocket and mailbox, so it’s the perfect choice. Another important aspect of the DL is that it’s the most cost-effective flyer size available, so if you’re on a budget, the DL is for you.

Square paper flyers are very specific. They stand out and, if the text is on point and the design is great, it can work wonders for businesses. If you want to give your face-to-face marketing a little oomph, this is the right choice for you. 

Basically, you have a flyer size for any type of need you may have. Make sure you take full advantage of this aspect when you create your flyer.

Design Tips for the Perfect Flyer

You have settled on the size, on the text and now it’s time you decided upon the overall aspect of your flyer. While it may sound like too much, because it’s only a flyer, you need to know that design is the most important element of your flyer.

Regardless of how interesting the text is, how perfectly you have chosen your flyer size, or how engaging your call-to-action is if the design of your flyer is icky, you may already deem it useless. There’s nothing worse than a boring flyer. 

So what can you do to make sure that your flyer rocks?

Anatomy of the Flyer

Although flyers can be extremely different from one another, their main anatomy and starting point are basically the same. Let’s see what this anatomy looks like:

  1. Headline – every flyer should have a title that stands out! This is what decides whether the rest of your flyer is going to be read or not. So make sure you have a great headline for your flyer.
  2. Body text – while some flyers might skip this step and only need a headline, the general rule is that you need some sort of text on your flyer, to explain why you’re handing it out or what you are promoting. Remember to make it snappy, short, and sweet.
  3. Fonts – try not to use more than 2 fonts on one flyer, as it can be overwhelming and counterproductive. Instead, try to find a font that is suitable for the message you want to send and make sure to integrate it well with your other design elements. The font you use can easily catch the attention of your target audience and that is an enormous plus.
  4. Call-to-action – whatever you are using this flyer for, you will surely need to explain to your readers what the next step is. Add the contact information, time, and address (if needed), and make sure you tell them specifically what you want them to do next.
  5. Design – we just talked about it and you already know how important it is to tie it all together. Make sure you put together a wonderful design or, if you lack inspiration, you can even use a readily-made template to design a flyer online, it’s surely going to make the whole endeavor easier.

As you can see, there aren’t many things that should be part of your flyer, but each and every one of these elements is important for the end result. 

I know it can sometimes feel overwhelming or even a difficult task to create a flyer from scratch, but there are enough online tools that can help you with that, just make sure you have the text on point and everything else can be easily taken care of.


Photo by Nao Takabayashi on Unsplash

Categories: Others Tags:

How We Improved Our Core Web Vitals (Case Study)

May 17th, 2021 No comments

Last year, Google started emphasizing the importance of Core Web Vitals and how they reflect a person’s real experience when visiting sites around the web. Performance is a core feature of our company, Instant Domain Search—it’s in the name. Imagine our surprise when we found that our vitals scores were not great for a lot of people. Our fast computers and fiber internet masked the experience real people have on our site. It wasn’t long before a sea of red “poor” and yellow “needs improvement” notices in our Google Search Console needed our attention. Entropy had won, and we had to figure out how to clean up the jank—and make our site faster.

I founded Instant Domain Search in 2005 and kept it as a side-hustle while I worked on a Y Combinator company (Snipshot, W06), before working as a software engineer at Facebook. We’ve recently grown to a small group based mostly in Victoria, Canada and we are working through a long backlog of new features and performance improvements. Our poor web vitals scores, and the looming Google Update, brought our focus to finding and fixing these issues.

When the first version of the site was launched, I’d built it with PHP, MySQL, and XMLHttpRequest. Internet Explorer 6 was fully supported, Firefox was gaining share, and Chrome was still years from launch. Over time, we’ve evolved through a variety of static site generators, JavaScript frameworks, and server technologies. Our current front-end stack is React served with Next.js and a backend service built-in Rust to answer our domain name searches. We try to follow best practice by serving as much as we can over a CDN, avoiding as many third-party scripts as possible, and using simple SVG graphics instead of bitmap PNGs. It wasn’t enough.

Next.js lets us build our pages and components in React and TypeScript. When paired with VS Code the development experience is amazing. Next.js generally works by transforming React components into static HTML and CSS. This way, the initial content can be served from a CDN, and then Next can “hydrate” the page to make elements dynamic. Once the page is hydrated, our site turns into a single-page app where people can search for and generate domain names. We do not rely on Next.js to do much server-side work, the majority of our content is statically exported as HTML, CSS, and JavaScript to be served from a CDN.

When someone starts searching for a domain name, we replace the page content with search results. To make the searches as fast as possible, the front-end directly queries our Rust backend which is heavily optimized for domain lookups and suggestions. Many queries we can answer instantly, but for some TLDs we need to do slower DNS queries which can take a second or two to resolve. When some of these slower queries resolve, we will update the UI with whatever new information comes in. The results pages are different for everyone, and it can be hard for us to predict exactly how each person experiences the site.

The Chrome DevTools are excellent, and a good place to start when chasing performance issues. The Performance view shows exactly when HTTP requests go out, where the browser spends time evaluating JavaScript, and more:

There are three Core Web Vitals metrics that Google will use to help rank sites in their upcoming search algorithm update. Google bins experiences into “Good”, “Needs Improvement”, and “Poor” based on the LCP, FID, and CLS scores real people have on the site:

  • LCP, or Largest Contentful Paint, defines the time it takes for the largest content element to become visible.
  • FID, or First Input Delay, relates to a site’s responsiveness to interaction—the time between a tap, click, or keypress in the interface and the response from the page.
  • CLS, or Cumulative Layout Shift, tracks how elements move or shift on the page absent of actions like a keyboard or click event.

Chrome is set up to track these metrics across all logged-in Chrome users, and sends anonymous statistics summarizing a customer’s experience on a site back to Google for evaluation. These scores are accessible via the Chrome User Experience Report, and are shown when you inspect a URL with the PageSpeed Insights tool. The scores represent the 75th percentile experience for people visiting that URL over the previous 28 days. This is the number they will use to help rank sites in the update.

A 75th percentile (p75) metric strikes a reasonable balance for performance goals. Taking an average, for example, would hide a lot of bad experiences people have. The median, or 50th percentile (p50), would mean that half of the people using our product were having a worse experience. The 95th percentile (p95), on the other hand, is hard to build for as it captures too many extreme outliers on old devices with spotty connections. We feel that scoring based on the 75th percentile is a fair standard to meet.

To get our scores under control, we first turned to Lighthouse for some excellent tooling built into Chrome and hosted at web.dev/measure/, and at PageSpeed Insights. These tools helped us find some broad technical issues with our site. We saw that the way Next.js was bundling our CSS and slowed our initial rendering time which affected our FID. The first easy win came from an experimental Next.js feature, optimizeCss, which helped improve our general performance score significantly.

Lighthouse also caught a cache misconfiguration that prevented some of our static assets from being served from our CDN. We are hosted on Google Cloud Platform, and the Google Cloud CDN requires that the Cache-Control header contains “public”. Next.js does not allow you to configure all of the headers it emits, so we had to override them by placing the Next.js server behind Caddy, a lightweight HTTP proxy server implemented in Go. We also took the opportunity to make sure we were serving what we could with the relatively new stale-while-revalidate support in modern browsers which allows the CDN to fetch content from the origin (our Next.js server) asynchronously in the background.

It’s easy—maybe too easy—to add almost anything you need to your product from npm. It doesn’t take long for bundle sizes to grow. Big bundles take longer to download on slow networks, and the 75th percentile mobile phone will spend a lot of time blocking the main UI thread while it tries to make sense of all the code it just downloaded. We liked BundlePhobia which is a free tool that shows how many dependencies and bytes an npm package will add to your bundle. This led us to eliminate or replace a number of react-spring powered animations with simpler CSS transitions:

Through the use of BundlePhobia and Lighthouse, we found that third-party error logging and analytics software contributed significantly to our bundle size and load time. We removed and replaced these tools with our own client-side logging that take advantage of modern browser APIs like sendBeacon and ping. We send logging and analytics to our own Google BigQuery infrastructure where we can answer the questions we care about in more detail than any of the off-the-shelf tools could provide. This also eliminates a number of third-party cookies and gives us far more control over how and when we send logging data from clients.

Our CLS score still had the most room for improvement. The way Google calculates CLS is complicated—you’re given a maximum “session window” with a 1-second gap, capped at 5 seconds from the initial page load, or from a keyboard or click interaction, to finish moving things around the site. If you’re interested in reading more deeply into this topic, here’s a great guide on the topic. This penalizes many types of overlays and popups that appear just after you land on a site. For instance, ads that shift content around or upsells that might appear when you start scrolling past ads to reach content. This article provides an excellent explanation of how the CLS score is calculated and the reasoning behind it.

We are fundamentally opposed to this kind of digital clutter so we were surprised to see how much room for improvement Google insisted we make. Chrome has a built-in Web Vitals overlay that you can access by using the Command Menu to “Show Core Web Vitals overlay”. To see exactly which elements Chrome considers in its CLS calculation, we found the Chrome Web Vitals extension’s “Console Logging” option in settings more helpful. Once enabled, this plugin shows your LCP, FID, and CLS scores for the current page. From the console, you can see exactly which elements on the page are connected to these scores. Our CLS scores had the most room for improvement.

Of the three metrics, CLS is the only one that accumulates as you interact with a page. The Web Vitals extension has a logging option that will show exactly which elements cause CLS while you are interacting with a product. Watch how the CLS metrics add when we scroll on Smashing Magazine’s home page:

The best way to track progress from one deploy to the next is to measure page experiences the same way Google does. If you have Google Analytics set up, an easy way to do this is to install Google’s web-vitals module and hook it up to Google Analytics. This provides a rough measure of your progress and makes it visible in a Google Analytics dashboard.

This is where we hit a wall. We could see our CLS score, and while we’d improved it significantly, we still had work to do. Our CLS score was roughly 0.23 and we needed to get this below 0.1—and preferably down to 0. At this point, though, we couldn’t find something that told us exactly which components on which pages were still affecting the score. We could see that Chrome exposed a lot of detail in their Core Web Vitals tools, but that the logging aggregators threw away the most important part: exactly which page element caused the problem.

To capture all of the detail we need, we built a serverless function to capture web vitals data from browsers. Since we don’t need to run real-time queries on the data, we stream it into Google BigQuery’s streaming API for storage. This architecture means we can inexpensively capture about as many data points as we can generate.

After learning some lessons while working with Web Vitals and BigQuery, we decided to bundle up this functionality and release these tools as open-source at vitals.dev.

Using Instant Vitals is a quick way to get started tracking your Web Vitals scores in BigQuery. Here’s an example of a BigQuery table schema that we create:

Integrating with Instant Vitals is easy. You can get started by integrating with the client library to send data to your backend or serverless function:

import { init } from "@instantdomain/vitals-client";

init({ endpoint: "/api/web-vitals" });

Then, on your server, you can integrate with the server library to complete the circuit:

import fs from "fs";

import { init, streamVitals } from "@instantdomain/vitals-server";

// Google libraries require service key as path to file
const GOOGLE_SERVICE_KEY = process.env.GOOGLE_SERVICE_KEY;
process.env.GOOGLE_APPLICATION_CREDENTIALS = "/tmp/goog_creds";
fs.writeFileSync(
  process.env.GOOGLE_APPLICATION_CREDENTIALS,
  GOOGLE_SERVICE_KEY
);

const DATASET_ID = "web_vitals";
init({ datasetId: DATASET_ID }).then().catch(console.error);

// Request handler
export default async (req, res) => {
  const body = JSON.parse(req.body);
  await streamVitals(body, body.name);
  res.status(200).end();
};

Simply call streamVitalswith the body of the request and the name of the metric to send the metric to BigQuery. The library will handle creating the dataset and tables for you.

After collecting a day’s worth of data, we ran this query like this one:

SELECT
  `<project_name>.web_vitals.CLS`.Value,
  Node
FROM
  `<project_name>.web_vitals.CLS`
JOIN
  UNNEST(Entries) AS Entry
JOIN
  UNNEST(Entry.Sources)
WHERE
  Node != ""
ORDER BY
  value
LIMIT
  10

This query produces results like this:

Value Node
4.6045324800736724E-4 /html/body/div[1]/main/div/div/div[2]/div/div/blockquote
7.183070668914928E-4 /html/body/div[1]/header/div/div/header/div
0.031002668277977697 /html/body/div[1]/footer
0.035830703317463526 /html/body/div[1]/main/div/div/div[2]
0.035830703317463526 /html/body/div[1]/footer
0.035830703317463526 /html/body/div[1]/main/div/div/div[2]
0.035830703317463526 /html/body/div[1]/main/div/div/div[2]
0.035830703317463526 /html/body/div[1]/footer
0.035830703317463526 /html/body/div[1]/footer
0.03988482067913317 /html/body/div[1]/footer

This shows us which elements on which pages have the most impact on CLS. It created a punch list for our team to investigate and fix. On Instant Domain Search, it turns out that slow or bad mobile connections will take more than 500ms to load some of our search results. One of the worst contributors to CLS for these users was actually our footer.

The layout shift score is calculated as a function of the size of the element moving, and how far it goes. In our search results view, if a device takes more than a certain amount of time to receive and render search results, the results view would collapse to a zero-height, bringing the footer into view. When the results come in, they push the footer back to the bottom of the page. A big DOM element moving this far added a lot to our CLS score. To work through this properly, we need to restructure the way the search results are collected and rendered. We decided to just remove the footer in the search results view as a quick hack that’d stop it from bouncing around on slow connections.

We now review this report regularly to track how we are improving — and use it to fight declining results as we move forward. We have witnessed the value of extra attention to newly launched features and products on our site and have operationalized consistent checks to be sure core vitals are acting in favor of our ranking. We hope that by sharing Instant Vitals we can help other developers tackle their Core Web Vitals scores too.

Google provides excellent performance tools built into Chrome, and we used them to find and fix a number of performance issues. We learned that the field data provided by Google offered a good summary of our p75 progress, but did not have actionable detail. We needed to find out exactly which DOM elements were causing layout shifts and input delays. Once we started collecting our own field data—with XPath queries—we were able to identify specific opportunities to improve everyone’s experience on our site. With some effort, we brought our real-world Core Web Vitals field scores down into an acceptable range in preparation for June’s Page Experience Update. We’re happy to see these numbers go down and to the right!

Categories: Others Tags: