User Experience (UX) is more than the arrangement of pages on a website. It is the combined impact that your brand creates for potential buyers.
It is the feeling that these buyers get when they interact with your content. It is the sum collection of impulses that will lead to their making a purchase…or not. In short, UX is one of the most absolutely fundamental aspects of the user-website (and by extension, the user-brand) relationship, and one that no company can afford to treat thoughtlessly.
There are countless ways to approach UX design, from focussing on an intuitive site layout to creating eye-popping graphics or persuasive, compelling text. But as video content continually proves to be one of the most popular and successful forms of content marketing, why not integrate it with your existing User Experience for a more engaging multi-channel approach? Through the power of video content, there’s no limits to the ways that you can draw in new potential customers, keep them engaged longer than ever before, and ultimately convert them to brand loyalists.
To help you out, here are five effective concepts for improving your website’s UX with video content:
1. Welcome Video
Your homepage is arguably the most important part of your User Experience, because this is the very first impression that potential buyers will have of your brand. Don’t let this opportunity slip away by not taking time to optimize your homepage’ as much as possible – and what better way to do so than with a stylish welcome video? Studies show that viewers who watch a video have a 95% retention rate of the information they receive from it, versus just 10% when that same information is read in text form. That’s why a welcome video will let you quickly introduce all the most important aspects of your brand or company in one succinct piece of content that audiences are guaranteed to retain. And even a wordless one, like the background video featured on the Lemonlight homepage, can help hook viewers right away by showing off your brand’s aesthetic.
2. Product Videos
When potential buyers click through products on most websites, they are greeted with static, ugly images and dull descriptions. With video, you can dramatically improve their perception of your products or services and stand out from the crowd. Create short-form content pieces that illustrate the benefits of each product in action, like mini commercials, rather than trusting your audience to understand based off of a couple grainy photos. These videos will help build viewers’ faith that your product will work for their needs, and act as a key deciding factor between yours and other similar products. The majority of customers prefer demo videos to written text, so give them what they already want and substantially improve your engagement along the way!
3. Testimonial Videos
Brands love to feature positive reviews and glowing endorsements as part of their UX, but walls of stars awarded by some obscure magazine will only take you so far. Audiences connect much more with a human face than a well-respected industry title, so why not create video testimonials where your most enthusiastic customers can authentically express their love for what you do? Customer testimonials are already considered to be the most effective content marketing tactic by industry professionals, and by combining them with videos they become exponentially more useful for humanizing your brand. Remember, people don’t buy from companies. They buy from other people – which is why testimonial videos always put those people front and center.
4. Team Videos
We already mentioned that having a warm human presence is essential to connecting with your customers. After all, nobody wants to make a purchase from some cold, faceless corporation if they don’t have to. That’s why the next natural step after using video to introduce your favorite customers (via their testimonials) is to use it to introduce your team. Whether it’s a quick to-camera interview with your CEO featured on an “About Us” section or a more playful event montage from your annual office holiday party, team videos are terrific for showing that audiences can trust you – because you’re just like them! They can also help illuminate every individual’s role in your company so that viewers have a better, more confident understanding of what they will receive by investing in your process.
5. Case Study Videos
Like a combination of product and testimonial videos, case study videos allow you to break down the impact that your product/service has had in the past on real, paying customers. Rather than subject potential buyers to dry, static graphs or spreadsheets, a case study video brings that same essential data to life in an invigorating way that is guaranteed to create deeper retention. Enhance your case study video with animation for an added boost that can make even the most intimidating numbers fun to engage with.
When you add video to your User Experience, you are not just redesigning your website – you are taking a bold, strategic approach to wooing potential customers across the spectrum. Try any of these ideas for a leg up on the competition, then watch conversion rates grow as your audience discovers just how brilliantly they can engage with your brand.
Unfortunately, over half (54%) of the businesses surveyed for the 2018 State of SMB Cybersecurity report believe they’re too small to be a target for hackers. But the data paints a different picture:
67% of small- and medium-sized businesses were attacked in 2018;
82% of those attacked had antivirus software installed on their systems;
72% had intrusion detection systems in place.
In reality, businesses aren’t failing to secure their websites because they believe they’re too small to attract the attention of hackers. The truth is, most point to a lack of resources to explain why they forego security. Here are the top three reasons given:
We don’t have enough personnel to manage security;
We don’t have enough money to pay for it;
We don’t know a thing about security or where to start.
But here’s the thing: websites are not difficult or expensive to secure. You just need to know which security measures are absolutely necessary for a website to have and where to procure them.
Here’s where you should start…
Find a Secure Web Host
Your choice of web host can affect your website in a number of ways, including how well it’s protected from hackers.
For starters, if security is at all a concern for you (or the client you’re building the site for), then a shared hosting plan won’t be ideal. If any website on the shared server is attacked, it could easily spread to your own.
Secondly, if your web host doesn’t prioritize security on its end, it’s a good idea to look elsewhere. While many web hosts do a good job of this, be wary of the ones who provide no information about their dataccenters, how their assets are secured, or what level of security has been implemented (e.g. physical facility monitoring, server firewalls, etc.).
Finally, look for a web hosting plan with built-in security features. It’s not necessary for hosts to go above and beyond with this, but it’s a good sign when they’re willing to lend a hand.
Use a SSL Certificate
One of those security features your web host should be able to throw in (even if it’s a paid upgrade) is an SSL certificate. It’s a form of encryption that turns a regular ol’ unsecured HTTP website:
Into one with an extra layer of protection and an HTTPS address:
You can see how my Chrome address bar calls attention to the differences in security. HTTP websites receive a “Not Secure” label while HTTPS get a trust mark either in the form of a lock or a green label.
Google’s algorithm does something similar when it ranks websites, penalizing those without this security feature and rewarding those that have it.
Use Well-Coded Software
While you may be able to control how you design or code a website on the front end, you may not have a lot of control over the code behind it all. What’s more, any time you add a new extension, the integrity of that code now has a chance to affect your site as well.
To start, choose your software wisely, including:
Your website builder solution or content management system;
Your theme or design template;
Your extensions or plugins.
Even if you don’t know how to review the integrity of the code, look at user reviews. Are there any glaring issues with vulnerabilities introduced by the software? If so, steer clear.
In addition, the software developers should always be working to improve it. That’s why, depending on which software you use, you may see the occasional update to patch bugs, performance issues, and vulnerabilities.
If you don’t see these updates or the provider has a reputation for not supporting their software, that’s another reason to find another solution.
Maintain a Strongly-Enforced Password Policy
With each new application we add to our workflow, a new password needs to be generated. And while you might know that it’s bad practice to use the same or similar passwords across all applications, do your clients? Or anyone else with access to the website?
A weak login is the easiest way for a hacker to get inside a website. By enforcing a password policy across the board, you can help safe-guard against brute force attacks.
Now, some site builder solutions enable you to hide the login URL or to implement two-factor authentication. It’s a good idea to take advantage of those if you can. I’d also suggest requiring stronger passwords.
A long string of letters, numbers, symbols, and capitalization will help hackers from being able to guess your users’ login information.
Use a Spam Blocker
Even if spam isn’t too much of a concern, it’s a good idea to keep it from ever going near your website, even if just to remove the nuisance factor.
To protect your contact and comment forms from spam, there are a few things you can do. You can use a spam-blocking plugin, which turns spam into an out-of-sight, out-of-mind matter. You can use a reCAPTCHA like the one used on this website:
It’s just an extra step humans need to take to confirm their human-ness.
You can also implement a honeypot. Essentially, it’s a hidden field laid down as a trap in a form. Humans can’t see it and, so, they won’t know to fill it out. Spam bots, however, will see it and fill it out.
All-in-One Security Plugin
Ideally, your website should be running on a secure server. However, it’s not really the host’s job to ensure that your website is protected from every angle.
To make sure your website is covered as much as possible, look for a high-quality, all-in-one security plugin. It should include things like:
A firewall
Brute force protection
Spam prevention
User registration and access limitations
Database and file security
It should also have a monitoring system built it. It will alert you to things like too many failed login attempts, unexpected file changes, and so on.
Always Backup Your Files
Finally, don’t forget to have a backup system in place. If all of the security measures above fail, you’ll want a recent backup of the website you can fall back to in order to restore your website to safety.
Some web hosts may include backups in your web hosting plan, but it’s also a good idea to automate the process with a backup plugin and then store frequently saved copies of your site in a safe and remote location (like a free Amazon S3 account).
Why Website Security Should Concern You
Hackers are creative. They can get into a website from a comment form, through the login page, and from an exposed file on the backend (among other methods). If a vulnerability exists, they will find it.
Unfortunately, when a website is left open to attack, it can have devastating consequences for a business:
Loss of control over the website
Stolen records
Loss of customer trust
Damaged reputation
Google blacklisting
And more
As the designer or developer who built the website for them, failing to properly secure it could be just as harmful to your business. So, it’s best to know what you can do to implement, at the very least, a minimum amount of security to every website you build.
In modern front-end development, developers should aim to write CSS which is scalable and maintainable. Otherwise, they risk losing control over specifics such as the cascade and selector specificity as the codebase grows and more developers contribute.
One way this can be achieved is through the use of methodologies such as Object-Oriented CSS (OOCSS), which rather than organizing CSS around page context, encourages separating structure (grid systems, spacing, widths, etc.) from decoration (fonts, brand, colors, etc.).
So CSS class names such as:
.blog-right-column
.latest_topics_list
.job-vacancy-ad
Are replaced with more reusable alternatives, which apply the same CSS styles, but aren’t tied to any particular context:
.col-md-4
.list-group
.card
This approach is commonly implemented with the help of a SASS framework such as Bootstrap, Foundation, or increasingly more often, a bespoke framework which can be shaped to better fit the project.
So now we’re using CSS classes cherry-picked from a framework of patterns, UI components and utility classes. The below example illustrates a common grid system built using Bootstrap, which stacks vertically, then once the md breakpoint is reached, switches to a 3 column layout.
Programmatically generated classes such as .col-12 and .col-md-4 are used here to create this pattern. But what about .col-1 through .col-11, .col-lg-4, .col-md-6 or .col-sm-12? These are all examples of classes which will be included in the compiled CSS stylesheet, downloaded and parsed by the browser, despite not being in use.
In this article, we’ll start by exploring the impact unused CSS can have on page load speeds. We’ll then touch upon some existing solution for removing it from stylesheets, following up with my own SASS oriented solution.
Measuring The Impact Of Unused CSS Classes
Whilst I adore Sheffield United, the mighty blades, their website’s CSS is bundled into a single 568kb minified file, which comes to 105kb even when gzipped. That seems like a lot.
Shall we see how much of this CSS is actually used by on their homepage? A quick Google search reveals plenty of online tools up to the job, but I prefer to use the coverage tool in Chrome, which can be run straight from Chrome’s DevTools. Let’s give it a whirl.
The results show that only 30kb of CSS from the 568kb stylesheet is used by the homepage, with the remaining 538kb relating to the styles required for the rest of the website. This means a whopping 94.8% of the CSS is unused.
CSS is part of a webpage’s critical rendering path, which involves all the different steps a browser must complete before it can begin page render. This makes CSS a render-blocking asset.
So with this in mind, when loading Sheffield United’s website using a good 3G connection, it takes a whole 1.15s before the CSS is downloaded and page rendering can begin. This is a problem.
Google has recognized this as well. When running a Lighthouse audit, online or via your browser, any potential load time and filesize savings which could be made by removing unused CSS are highlighted.
Existing Solutions
The goal is to determine which CSS classes aren’t required and remove them from the stylesheet. Existing solutions are available which attempt to automate this process. They can typically be used via a Node.js build script, or via task runners such as Gulp. These include:
On bulld, the website is accessed via a headless browser (Eg: puppeteer) or DOM emulation (Eg: jsdom).
Based on the page’s HTML elements, any unused CSS is identified.
This is removed from the stylesheet, leaving only what is needed.
Whilst these automated tools are perfectly valid and I’ve used many of them across a number of commercial projects successfully, I’ve encountered a few drawbacks along the way which are worth sharing:
If class names contain special characters such as ‘@’ or ‘/’, these may not be recognized without writing some custom code. I use BEM-IT by Harry Roberts, which involves structuring class names with responsive suffixes like: u-width-6/12@lg, so I’ve hit this issue before.
If the website uses automated deployment, it can slow down the build process, especially if you have lots of pages and lots of CSS.
Knowledge about these tools needs to be shared across the team, otherwise there may be confusion and frustration when CSS is mysteriously absent in production stylesheets.
If your website has many 3rd party scripts running, sometimes when opened in a headless browser, these don’t play nicely and can cause errors with the filtering process. So typically you have to write custom code to exclude any 3rd party scripts when a headless browser is detected, which depending on your setup, may be tricky.
Generally, these kind of tools are complicated and introduce a lot of extra dependencies to the build process. As is the case with all 3rd party dependencies, this means relying on somebody else’s code.
With these points in mind, I posed myself a question:
Using just SASS, is it possible to better handle the SASS we compile so any unused CSS can be excluded, without resorting to just crudely deleting the source classes in the SASS outright?
Spoiler alert:The answer is yes. Here’s what I’ve come up with.
SASS Oriented Solution
The solution needs to provide a quick and easy way to cherry-pick what SASS ought to be compiled, whilst being simple enough that it doesn’t add any more complexity to the development process or prevent developers from taking advantage of things like programmatically generated CSS classes.
To get started, there’s a repo with build scripts and a few sample styles which you can clone from here.
cd into the repo, run npm install and then npm run build to compile any SASS into CSS as required. This should create a 55kb css file in the dist directory.
If you then open /dist/index.html in your web browser, you should see a fairly standard component, which on click expands to reveal some content. You can also view this here, where real network conditions will be applied, so you can run your own tests.
Filtering At The Partials Level
In a typical SCSS setup, you’re likely going to have a single manifest file (eg: main.scss in the repo), or one per page (eg: index.scss, products.scss, contact.scss) where framework partials are imported. Following OOCSS principles, those imports may look something like this:
If any of these partials aren’t in use, then the natural way of filtering this unused CSS would be to just disable the import, which would prevent it from being compiled.
For example, if only using the expander component, the manifest would typically look like the below:
However, as per OOCSS, we’re separating decoration from structure to allow for maximum reusability, so it’s possible the expander could require CSS from other objects, component or utility classes to render correctly. Unless the developer is aware of these relationships by inspecting the HTML, they may not know to import these partials, so not all of the required classes would be compiled.
In the repo, if you look at the expander’s HTML in dist/index.html, this appears to be the case. It uses styles from the box and layout objects, the typography component, and width and alignment utilities.
Let’s tackle this problem waiting to happen by making these relationships official within the SASS itself, so once a component is imported, any dependencies will also be imported automatically. This way, the developer no longer has the extra overhead of having to audit the HTML to learn what else they need to import.
Programmatic Imports Map
For this dependency system to work, rather than simply commenting in @import statements in the manifest file, SASS logic will need to dictate if partials will be compiled or not.
In src/scss/settings, create a new partial called _imports.scss, @import it in settings/_core.scss, and then create the following SCSS map:
It should behave like a standard set of @imports would, in that if certain partials are commented out (like the above), then that code shouldn’t be compiled on build.
But as we’re wanting to import dependencies automatically, we should also be able to ignore this map under the right circumstances.
Render Mixin
Let’s start to add some SASS logic. Create _render.scss in src/scss/tools, and then add its @import to tools/_core.scss.
In the file, create an empty mixin called render().
src/scss/tools/_render.scss
@mixin render() {
}
In the mixin, we need to write SASS which does the following:
render() “Hey there $imports, fine weather isn’t it? Say, do you have the container object in your map?”
$imports false
render() “That’s a shame, looks like its won’t be compiled then. How about the button component?”
$imports true
render() “Nice! That’s the button being compiled then. Say hi to the wife for me.”
Basically, check if the partial is included in the $imports variable, and if so, render it using SASS’s @content directive, which allows us to pass a content block into the mixin.
We would use it like so:
Example 5
@include render('button', 'component') {
.c-button {
// styles et al
}
// any other class declarations
}
Before using this mixin, there’s a small improvement which we can make to it. The layer name (object, component, utility, etc.) is something we can safely predict, so we have an opportunity to streamline things a little.
Before the render mixin declaration, create a variable called $layer, and remove the identically named variable from the mixins parameters. Like so:
Now, in the _core.scss partials where objects, components and utility @imports are located, redeclare these variables to the following values; representing the type of CSS classes being imported.
This way, when we use the render() mixin, all we have to do is declare the partial name.
Wrap the render() mixin around each object, component and utility class declaration, as per the below. This will give you one render mixin usage per partial.
For example:
src/scss/objects/_layout.scss
@include render('button') {
.c-button {
// styles et al
}
// any other class declarations
}
src/scss/components/_button.scss
@include render('button') {
.c-button {
// styles et al
}
// any other class declarations
}
Note: For utilities/_widths.scss, wrapping the render() function around the entire partial will error on compile, as in SASS you can’t nest mixin declarations within mixin calls. Instead, just wrap the render() mixin around the create-widths() calls, like below:
@include render('widths') {
// GENERATE STANDARD WIDTHS
//---------------------------------------------------------------------
// Example: .u-width-1/3
@include create-widths($utility-widths-sets);
// GENERATE RESPONSIVE WIDTHS
//---------------------------------------------------------------------
// Create responsive variants using settings.breakpoints
// Changes width when breakpoint is hit
// Example: .u-width-1/3@md
@each $bp-name, $bp-value in $mq-breakpoints {
@include mq(#{$bp-name}) {
@include create-widths($utility-widths-sets, @, #{$bp-name});
}
}
// End render
}
With this in place, on build, only the partials referenced in $imports will be compiled.
Mix and match what components are commented out in $imports and run npm run build in the terminal to give it a try.
Dependencies Map
Now we’re programmatically importing partials, we can start to implement the dependency logic.
In src/scss/settings, create a new partial called _dependencies.scss, @import it in settings/_core.scss, but make sure it’s after _imports.scss. Then in it, create the following SCSS map:
Here, we declare dependencies for the expander component as it requires styles from other partials to render correctly, as seen in dist/index.html.
Using this list, we can write logic which would mean these dependencies would always be compiled along with their dependent components, no matter the state of the $imports variable.
Below $dependencies, create a mixin called dependency-setup(). In here, we’ll do the following actions:
So what we have now is an enhanced partial import system, where if a component is imported, a developer doesn’t then have to manually import each of its various dependency partials as well.
Configure the $imports variable so only the expander component is imported and then run npm run build. You should see in the compiled CSS the expander classes along with all of its dependencies.
However, this doesn’t really bring anything new to the table in terms of filtering out unused CSS, as the same amount of SASS is still being imported, programmatic or not. Let’s improve on this.
Improved Dependency Importing
A component may require only a single class from a dependency, so to then go on and import all of that dependency’s classes just leads to the same unnecessary bloat we’re trying to avoid.
We can refine the system to allow for more granular filtering on a class by class basis, to make sure components are compiled with only the dependency classes they require.
With most design patterns, decorated or not, there exists a minimum amount of classes which need to be present in the stylesheet for the pattern to display correctly.
For class names using an established naming convention such as BEM, typically the “Block” and “Element” named classes are required as a minimum, with “Modifiers” typically being optional.
Note:Utility classes wouldn’t typically follow the BEM route, as they’re isolated in nature due to their narrow focus.
For example, take a look at this media object, which is probably the most well-known example of object-oriented CSS:
If a component has this set as a dependency, it makes sense to always compile .o-media, .o-media__image and .o-media__text, as that’s the minimum amount of CSS required to make the pattern work. However with .o-media--spacing-small being an optional modifier, it ought to only be compiled if we explicitly say so, as its usage may not be consistent across all media object instances.
We’ll modify the structure of the $dependencies map to allow us to import these optional classes, whilst including a way to import only the block and element in case no modifiers are required.
To get started, check the expander HTML in dist/index.html and make a note of any dependency classes in use. Record these in the $dependencies map, as per below:
Where a value is set to true, we’ll translate this into “Only compile block and element level classes, no modifiers!”.
The next step involves creating a whitelist variable to store these classes, and any other (non-dependency) classes we wish to manually import. In /src/scss/settings/imports.scss, after $imports, create a new SASS list called $global-filter.
src/scss/settings/_imports.scss
$global-filter: ();
The basic premise behind $global-filter is that any classes stored here will be compiled on build as long as the partial they belong to is imported via $imports.
These class names could be added programmatically if they’re a component dependency, or could be added manually when the variable is declared, like in the example below:
Next, we need to add a bit more logic to the @dependency-setup mixin, so any classes referenced in $dependencies are automatically added to our $global-filter whitelist.
Below this block:
src/scss/settings/_dependencies.scss
@if not index(map-get($imports, $layerKey), $partKey) {
}
Now we’ve got a class whitelist, we need to enforce this across all of the different object, component and utility partials.
Create a new partial called _filter.scss in src/scss/tools and add an @import to tools layer’s _core.scss file.
In this new partial, we’ll create a mixin called filter(). We’ll use this to apply logic which means classes will only be compiled if included in the $global-filter variable.
Starting off simple, create a mixin which accepts a single parameter — the $class which the filter controls. Next, if the $class is included in the $global-filter whitelist, allow it to be compiled.
This means the .o-myobject--modifier class would only be compiled if its included in $global-filter, which can either be set directly, or indirectly through what’s set in $dependencies.
Go through the repo and apply the filter() mixin to all optional modifier classes across object and component layers. When handling the typography component or the utilities layer, as each class is independent from the next, it’d make sense to make them all optional, so we can then just enable classes as we need them.
As the filter only accepts a single class, it doesn’t account for the possibility that one style declaration block may be for more than one class.
To account for this, we’ll expand the filter() mixin so in addition to a single class, it’s able to accept a SASS arglist containing many classes. Like so:
So we need to tell the filter() mixin that if either of these classes are in the $global-filter, you are allowed to compile the classes.
This will involve additional logic to type check the mixin’s $class argument, responding with a loop if an arglist is passed to check if each item is in the $global-filter variable.
Then it’s just a matter of going back to the following partials to correctly apply the filter() mixin:
objects/_box.scss
objects/_layout.scss
utilities/_alignments.scss
At this point, go back to $imports and enable just the expander component. In the compiled stylesheet, besides the styles from the generic and elements layers, you should only see the following:
The block and element classes belonging to the expander component, but not its modifier.
The block and element classes belonging to the expander’s dependencies.
Any modifier classes belonging to the expander’s dependencies which are explicitly declared in the $dependencies variable.
Theoretically, if you decided you wanted to include more classes in the compiled stylesheet, such as the expander components modifier, it’s just a matter of adding it to the $global-filter variable at the point of declaration, or appending it at some other point in the codebase (As long as it’s before the point where the modifier itself is declared).
Enabling Everything
So we now have a pretty complete system, which lets you import objects, components and utilities down to the individual classes within these partials.
During development, for whatever reason, you may just want to enable everything in one go. To allow for this, we’ll create a new variable called $enable-all-classes, and then add in some additional logic so if this is set to true, everything is compiled no matter the state of the $imports and $global-filter variables.
First, declare the variable in our main manifest file:
Then we just need to make a few minor edits to our filter() and render() mixins to add some override logic for when the $enable-all-classes variable is set to true.
First up, the filter() mixin. Before any existing checks, we’ll add an @if statement to see if $enable-all-classes is set to true, and if so, render the @content, no questions asked.
So now, if you were to set the $enable-all-classes variable to true and rebuild, every optional class would be compiled, saving you quite a bit of time in the process.
Comparisons
To see what type of gains this technique is giving us, let’s run some comparisons and see what the filesize differences are.
To make sure the comparison is a fair one, we ought to add the box and container objects in $imports, and then add the box’s o-box--spacing-regular modifier to the $global-filter, like so:
This makes sure styles for the expander’s parent elements are being compiled like they would be if there were no filtering taking place.
Original vs Filtered Stylesheets
Let’s compare the original stylesheet with all classes compiled, against the filtered stylesheet where only CSS required by the expander component has been compiled.
You may think that the gzip percentage savings mean this isn’t worth the effort, as there’s not much difference between the original and filtered stylesheets.
It’s worth highlighting that gzip compression works better with larger and more repetitive files. Because the filtered stylesheet is the only proof-of-concept, and only contains CSS for the expander component, there isn’t as much to compress as there would be in a real-life project.
If we were to scale up each stylesheet by a factor of 10 to sizes more typical of a website’s CSS bundle size, the difference in gzip file sizes are much more impressive.
10x Size
Stylesheet
Size (kb)
Size (gzip)
Original (10x)
892.07kb
75.70kb
Filtered (10x)
209.45kb (77% smaller)
19.47kb (74% smaller)
Filtered Stylesheet vs UNCSS
Here’s a comparison between the filtered stylesheet and a stylesheet which has been run through the UNCSS tool.
Filtered vs UNCSS
Stylesheet
Size (kb)
Size (gzip)
Filtered
15.34kb
4.91kb
UNCSS
12.89kb (16% smaller)
4.25kb (13% smaller)
The UNCSS tool wins here marginally, as it’s filtering out CSS in the generic and elements directories.
It’s possible that on a real website, with a larger variety of HTML elements in use, the difference between the 2 methods would be negligible.
Wrapping Up
So we’ve seen how — using just SASS — you are able to gain more control over what CSS classes are being compiled on build. This reduces the amount of unused CSS in the final stylesheet and speeds up the critical rendering path.
At the start of the article, I listed some drawbacks of existing solutions such as UNCSS. It’s only fair to critique this SASS-oriented solution in the same way, so all the facts are on the table before you decide which approach is better for you:
Pros
No additional dependencies required, so you don’t have to rely on somebody else’s code.
Less build time required than Node.js based alternatives, as you don’t have to run headless browsers to audit your code. This is especially useful with continuous integration as you may be less likely to see a queue of builds.
Results in similar file size when compared to automated tools.
Out of the box, you have complete control over what code is being filtered, regardless of how those CSS classes are used in your code. With Node.js based alternatives, you often have to maintain a separate whitelist so CSS classes belonging to dynamically injected HTML aren’t filtered out.
Cons
The SASS-oriented solution is definitely more hands-on, in the sense that you have to keep on top of the $imports and $global-filter variables. Beyond the initial setup, the Node.js alternatives we’ve looked at are largely automated.
If you add CSS classes to $global-filter and then later remove them from your HTML, you need to remember to update the variable, otherwise you’ll be compiling CSS you don’t need. With large projects being worked on by multiple devs at any one time, this may not be easy to manage unless you properly plan for it.
I wouldn’t recommend bolting this system onto any existing CSS codebase, as you’d have to spend quite a bit of time piecing together dependencies and applying the render() mixin to a LOT of classes. It’s a system much easier to implement with new builds, where you don’t have existing code to contend with.
Hopefully you’ve found this as interesting to read as I’ve found it interesting to put together. If you have any suggestions, ideas to improve this approach, or want to point out some fatal flaw that I’ve missed entirely, be sure to post in the comments below.
In this week’s roundup, variable fonts get oblique, a new browser extension for linting, and the very first version of CSS Modules.
Use font-style: oblique on variable fonts
Some popular variable fonts have a 'wght' (weight) axis for displaying text at different font weights and a 'slnt' (slant) axis for displaying slanted text. This enables creating many font styles using a single variable font file (e.g., see the “Variable Web Typography” demo page).
You can use font-style: oblique instead of the lower-level font-variation-settings property to display slanted text in variable fonts that have a 'slnt' axis. This approach works in Chrome, Safari, and Firefox.
The webhint linting tool is now available as a browser devtools extension for Chrome, Edge, and Firefox (read Microsoft’s announcement). Compared to Lighthouse, one distinguishing feature of webhint are its cross-browser compatibility hints.
In other news…
CSS Modules V1 is a new proposal from Microsoft that would extend the JavaScript modules infrastructure to allow importing a CSSStyleSheet object from a CSS file (e.g., import styles from "styles.css";) (via Thomas Steiner)
Web apps installed in the desktop version of Chrome can be uninstalled on the about:apps page (right-click on an app’s icon to reveal the Remove... option) (via Techdows)
Because of AMP’s unique requirements, larger news sites such as The Guardian should optimally have two separate codebases (one for the AMP pages and one for the regular website) (via The Guardian)
Read more news in my new, weekly Sunday issue. Visit webplatform.news for more information.
It is technically true that anyone can cook. But there’s a difference between actually knowing how to prepare a delicious meal and hoping for the best as you throw a few ingredients in a pot. Just like web development, you might know the ingredients—, background-color, .heading-1—but not everyone knows how to turn those ingredients into a beautiful, easy-to-use website.
Whenever you use HTML and CSS, you are designing—giving form and structure to content so it can be understood by someone else. People have been designing for centuries and have developed principles along the way that are applicable to digital interfaces today. These principles manifest in three key areas: how words are displayed (typography), how content is arranged (spacing), and how personalty is added (color). Let’s discover how to use each of these web design ingredients through the mindset of a developer with CSS properties and guidelines to take the guesswork out of web design.
Websites that are easy to read don’t happen by mistake. In fact, Taimur Abdaal wrote an entire article on the topic that’s chock-full of advice for developers working with type. We’re going to focus specifically on two fundamental principles of design that can help you display words in a more visually pleasing and easy-to-read way: repetition and hierarchy.
Use repetition for consistency and maintainability
Repetition comes fairly naturally on the web thanks to the importance of reusability in software. For example, CSS classes allow you to define a particular style for text and then reuse that style across the site. This results in repeating, consistent text styles for similar content which helps users navigate the site.
If, for example, you are working on styles for a new paragraph, first consider if there is existing content that has a similar style and try to use the same CSS class. If not, you can create a new class with a generic name that can be repeated elsewhere in your site. Think .paragraph--emphasize as opposed to .footer__paragraph--emphasize or .heading-1 as opposed to .hero__site-title. The first examples can be used across your site as opposed to the second which are scoped to specific components. You can even add a prefix like text- to indicate that the class is used specifically for text styles. This method will reduce the CSS file size and complexity while making it much easier to update global styles in the future.
In design, there are endless ways to experiment with styles. Designers can sometimes go a little crazy with their font styles by creating numerous slight variations of similar styles. However, in code, it’s valuable to restrict text styles to a minimum. Developers should urge designers to combine similar styles in order to reduce code weight and increase reusability and consistency.
Hierarchy provides a clear visual order to content
Hierarchy is something you really only notice when it’s not there. In typography, hierarchy refers to the visual difference between various pieces of text. It’s the distinction between headings, paragraphs, links, and other text styles. This distinction is made by choosing different fonts, colors, size, capitalization, and other properties for each type of text content. Good hierarchy makes complex information easier to digest and guides users through your content.
Out of the box, HTML provides some hierarchy (like how the font size of headings gets smaller as you go from
to ), but CSS opens the door for even more creativity. By giving tags an even larger font size, you can quickly establish greater difference in size between heading levels—and therefore more hierarchy. To create more variety, you can also change the color, text-align, and text-transform properties.
A note on choosing fonts
With typography, we need to make sure it is as easy to read as possible. The greatest overall factor in readability is the font you choose—which is a huge topic. There are many factors that determine how “readable” a font is. Some fonts are made specifically to be used as headings or short lines of text; these are called “display” fonts, and they often have more personality than fonts designed to be used for text. Unique flourishes and quirks make display fonts harder to read at small sizes and when part of a large paragraph. As a rule of thumb, use a more straightforward font for text and only use display fonts for headings.
If you’re in a pinch and need a readable font, try Google Fonts. Add a paragraph of text to the preview field and size it roughly how it will display on your website. You can then narrow down your results to serif or sans-serif and scan the list of fonts for one that is easy to read. Roboto, Noto Sans, Merriweather, and PT Serif are all very readable options.
CSS properties for better readability
The main paragraph font-size should be between 16pxand 18px (1em and 1.25em) depending on the font you choose.
Manually set line-height (the vertical space between two lines of text) to make your text less cramped and easier to read. Start with line-height: 1.25 (that is 1.25 times the font-size) for headings and at least 1.5 for paragraphs (but no more than 1.9) and adjust from there. The longer the line of text, the larger the line-height should be. To keep your text flexible, avoid adding a unit to your line-height. Without a unit the line-height you set will be proportional to your font-size. For example, line-height: 1.5 and font-size: 18px would give you a line height of 27 pixels. If you changed your font size to font-size: 16px on smaller screens, the computed line height would then change to 24 pixels automatically.
Pay attention to how many characters are in a line of text and aim for 45 and 75 characters long (including punctuation and spaces). Doing so reduces reading fatigue for your users by limiting the eye and head movement needed to follow a line of text. With the variable nature of the web, it’s impossible to completely control line length, but you can use max-width values and breakpoints to prevent lines of text from getting too long. Generally speaking, the shorter the line of text, the faster it will be to scan for quick reading. And don’t worry too much about counting the characters in every line. Once you do it a few times, you’ll develop a sense for what looks right.
Spacing
After looking at typography, you can take a step back and examine the layout, or spacing, of your content. Movement and proximity are two design principles that relate to spacing.
Movement is about content flow
Movement refers to how your eye moves through the page or the flow of the page. You can use movement to direct a user’s eye in order to tell a story, point to a main action item, or encourage them to scroll. This is done by structuring the content within individual components and then arranging those components to form the layout of the page. By paying attention to how your eye moves through content, you can help users know where to look as they scan the page.
Unlike books, which tend to have very linear structure, websites can be more creative with their layout—in literally endless ways. It is important to make sure you are intentional with how you layout content and do so in a way which guides users through your content as easily as possible.
Consider these three examples above. Which is the easiest to follow? The arrangement on the left draws your eye off the screen to the left due to how the image is positioned which makes it hard to find the button. In the center option, it’s easy to skip over the headline because the image is too large in comparison. On the right, the heading draws your attention first and the image is composed so that it points to the main action item—the button.
White space is a helpful tool for creating strong movement, but it’s easy to use too much or too little. Think about how you are using it to direct the user’s eye and divide your content. When used well, users won’t notice the whitespace itself but will be able to better focus on the content you are presenting. For example, you can use whitespace to separate content (instead of a colored box) which results in a less cluttered layout.
Proximity establishes relationships
When objects are closer together, they are perceived as being related. By controlling spacing around elements, you can imply relationships between them. It can be helpful to create a system for spacing to help build consistency through repetition and avoid the use of random numbers. This system is based off the default browser font size (1rem or 16px) and uses distinct values that cover most scenarios:
0.25rem (4px)
0.5rem (8px)
1rem (16px)
2rem (32px)
4rem (64px)
You can use Sass or CSS variables so that the values are kept consistent across the project. A system might look like this—but use whatever you’re comfortable with because naming things is hard:
$space-sm
$space-med
$space-lg
$space-xl
$space-xxl
Color conveys personality and calls attention
Color greatly affects a website’s personality. When used well, it gives pages life and emotion; used poorly, it can distract from the content, or worse, make it inaccessible. Color goes hand in hand with most design principles. It can be used to create movement by directing users’ eyes and can be used to create emphasis by calling attention to the most important action items.
A note on choosing colors
With color, it can be hard to know where to start. To help, you can use a four-step process to guide your color choices and build a color palette for the site.
Step 1: Know your mood
You have to know the mood or attitude of your site and brand before choosing colors. Look at your content and decide what you are trying to communicate. Is it funny, informative, retro, loud, somber? Typically, you can boil down the mood of your site to a few adjectives. For example, you might summarize The North Face as adventurous and rugged while Apple would be minimalistic and beautiful.
Step 2: Find your main color
With your mood in mind, try to visualize a color that represents it. Start with the color’s saturation (how intense the color is) and brightness (how close the color is to white or black). If your mood is upbeat or flashy, a lighter (more saturated) color is probably best. If your mood is serious or reserved, a darker (less saturated) color is better.
Next, choose a hue. Hue refers to what most people think of as colors—where does is fall on the rotation of the color wheel? The hue of a color is what gives it the most meaning. People tend to associate hues with certain ideas. For instance, red is often associated with power or danger and green relates to money or nature. It can be helpful to look at similar websites or brands to see what colors they use—although you don’t need to follow their lead. Don’t be afraid to experiment!
Step 3: Add supporting colors
Sometimes, two or three main colors are needed, but this is not necessary. Think about the colors of different brands. Some use a single color, and others have a main color and one or two that support it. Coca-Cola uses its distinct red. IKEA is mostly blue with some yellow. Tide is orange with some blue and yellow. Depending on your site’s mood, you might need a few colors. Try using a tool like Adobe Color or Coolors), both of which allow you to add a main color and then try different color relationships, like complementary or monochromatic, to quickly see if any work well.
Step 4: Expand your palette
Now that you’ve narrowed things down and found your main color(s), it’s time to expand your scope with a palette that gives your project versatility and constraint—here’s a methodology I’ve found helpful. Tints and shades are the trick here. Tints are made by mixing your main color(s) with white, and shades are made by mixing with black. You can quickly create an organized system with Sass color functions:
To round out your palette, you’ll need a few more colors, like a white and black. Try creating a “rich black” using a dark, almost black shade of your main color and, on the other end of the spectrum, pick a few light grays that are tinted with your main color. Tinting the white and black adds a little more personality to your page and helps create a cohesive look and feel.
Last but not least, if you are working on an interactive product, you should add colors for success, warning, and error states. Typically a green, yellow, and red work for these but consider how you can adjust the hue to make them fit better with your palette. For example, if your mood is friendly and your base color is green, you might want to desaturate the error state colors to make the red feel less negative.
You can do this with the mix Sass color function by giving it your base color, the default error color, and the percentage of base color that you want to mix in with the error color. Adding desaturate functions helps tone down the colors:
When it comes to the web, there’s one color principle that you have to pay extra attention to: contrast. That’s what we’ll cover next.
Contrast
Color contrast—the difference in saturation, brightness, and hue between two colors—is an important design principle for ensuring the web is accessible to those with low vision or color blindness. By ensuring there is enough contrast between your text and whatever is behind it on your site will be more accessible for all sighted users. When looking at accessibility, be sure to follow the color contrast guidelines provided by W3C‘s Web Content Accessibility Guidelines (WCAG). There are many tools that can help you follow these guidelines, including the inspect panel in Chrome’s dev tools.
Now, it’s time to put these principles to practice! You can use these processes and CSS tips to help take the guesswork out of design and create better solutions. Start with what you are familiar with, and eventually, the design principles mentioned here will become second nature.
If you’re on CSS-Tricks, we can probably bet that you’re in the process of building a really cool website. You’ve spent your time creating content, applying appropriate UX design techniques, coding it to perfection, and now you’re about ready to launch it to the world.
A great website deserves a domain name that represents all that you’ve built. With Hover, you have the flexibility to choose a domain name that truly reflects that. We offer not only the go-to domain name extensions, like .com and .org, or the familiar country code domain extensions, like .uk or .us, or .ca, but also the more niche extensions. We have .dev for developers, .design for designers, and .dog for your dog (yes, really!).
We have hundreds of domain names to choose from and all eligible domains come with free Whois privacy protection. We’re proud of the modern UX/UI and fabulous customer service we offer our customers. Find your next domain name with Hover!
It’s 2019, if you don’t have a video marketing strategy, you’re already behind. In order to make your brand succeed, video is no longer just helpful, it’s a must.
Since video isn’t a one-size-fits-all product, you can include it in your marketing plan easily and adapt it to your audience and your goals. With all the benefits video has shown it can produce, it only makes sense to make room for it in your plans. Don’t fall further behind and get your strategy right before you start making random video content.
Why Is Video So Important in 2019?
In the past, text posts may have been the norm online, but through the years, our way of communicating has become a lot more visual. This isn’t by mere coincidence either. Creating images and video content have become easier thanks to advances in technology. For example, video making tools are everywhere and can produce great results. Posting and sharing videos online has also become much simpler than in the past, encouraging people to do it more.
Marketers also know what they’re doing when they opt to use video to communicate with their audience instead of a long text post. It’s easy enough to say that video is more visually appealing, but the stats also show how significant its impact is. In fact, 93% of marketers have gotten new customers as a result of a video posted to social media and 72% of businesses attribute improved conversion rates to video content. With stats like this, it only makes sense to include video in your already existing marketing plan.
Define Your Target Audience
Now that you’re convinced you need a video marketing strategy, there’s more work to be done before you start making your first video. Put down the camera and first define the audience you want to reach with your content. Without specifying this basic target, your video efforts won’t have much guidance and won’t hit the mark. If you already have a marketing plan in place, use this to help you define your target and your goals as well.
To decide who your target is, you can start by selecting a broad group you want to reach with your message. This can be something as simple and general as women, men, or children. Instead of stopping there, narrow this group down even further using other characteristics like age, location, and niche interests. This will help you understand your audience much better, making it easier to deliver a video that really catches their eye.
Including video on landing pages and on your website is great practice, but you’ll also want to pay close attention to social media. Video content made specifically for your social accounts is a must because of the tremendous impact it can have. Each platform has pros and cons, different demographics, and a different reach, so get to know these thoroughly before you decide which platform will help you reach your target audience best.
What’s Your Objective?
After defining your target audience, you will also need to have a clearly established objective for your video content. This means you shouldn’t make videos just to make videos. Be sure each one has a specific goal you’re working to achieve. Common objectives for a video marketing strategy may include things like increased engagement, increased follower count, increased exposure, or increased revenue.
Once you have your goal clearly defined, creating targeted video content will be much easier. You will then be better prepared to develop a concept for your video that will help you reach that goal more effectively. Think of it as a guide for your efforts or literally a target you’re aiming at. For example, if your goal is to get the word out about a sale you’re having, then a promo video that clearly highlights your best deals will be ideal. Not sure what type of video to use? Check out some of the most common types below:
Promo video: Use this type of video to promote your brand, a new product, a sale, or anything else.
Intro video: An intro video, like a logo animation, is a great option to introduce a new brand or project. If you don’t have animation skills, create a cool intro easily using and intro maker.
Testimonial video: These are a great way to show potential customers the great reviews you’ve received from already existing customers.
Step by step video: Teach your followers how to use your products or share a cool tutorial with them. Create these types of videos easily with a slideshow maker.
Posting Your Video Content on Social Media
Where you post your video matters. As we mentioned earlier, creating one video and posting it everywhere won’t have the best results. Since each social media platform has its quirks, you’ll need to make content that makes sense for each one. It’s also worth noting that each platform has different guidelines for videos, including time limits, ratios, and posting possibilities. What you can do is come up with a concept and adapt it to all of the platforms you want to post on.
To help you make the perfect content for each social networking site, check out these basic guidelines for the most important social networks:
Facebook: This social network is popular with just about all demographics. It’s great for running targeted video ads because of it’s easy to use ads manager tool. You can post landscape, portrait, or even 1:1 aspect ratio videos. Facebook has tons of options for video posting, including regular in-feed videos, Facebook stories, Facebook canvas, video carousel ads, and so much more.
Instagram: Instagram is loved by millennials, but keep in mind that Gen X is also fond of this very visual platform. While you can post vertical, horizontal, or square videos on Instagram, the 1:1 ratio square videos are what look best. For in-feed videos, you have a limit of 60 seconds to get your message across. Stories should be 15 seconds at their longest and in a vertical orientation. Although stories are shorter, their format means your content will take up the entire screen, meaning fewer distractions. You can also get your audience to connect with you through elements like polls, questions, and quizzes.
Twitter: This platform allows you to share video either in portrait or landscape orientation. Make your videos for Twitter no longer than 140 seconds.
YouTube: YouTube is basically a search engine, so you can reach just about any demographic or niche on this platform designed for video content. Videos can be up to 12 hours long and are supported in two ratios, 16:9 and 4:3. To ensure your videos are found by your audience, use your knowledge of SEO to create titles and descriptions that will help them pop up in the search results page. Don’t forget to brand your videos with your logo. If you don’t have a logo you love, create your own using a quick and easy tool like an online logo maker.
Plan Your Content
Now that you have a clear target audience, a goal, and you know where you will be posting your video, it’s time to actually create it. The type of video you’re making will define a lot of the content in it. For example, if you’re creating a promo video, it only makes sense to include information about the deals you have, make it exciting for your target audience, and use images that reflect your brand. Other important aspects to keep in mind while developing your video’s content include:
Make it relevant to your target: Create videos that your audience will useful or interesting.
Ensure it’s easy to understand: Don’t overcomplicate things. Keep your video’s message clear and concise.
Make it enticing and exciting: Make video content that stands out and that really catches the attention of your audience.
Keep your video short: Short videos tend to perform better than videos that are too long and dragged out. Keep it short and to the point.
Include sound: Although most videos posted to social media start with the sound off, it’s still good practice to include some background music. Of course, keep in mind that your video should still function without it because many viewers will likely watch it without sound,
Make it helpful and informative: Make video content that will be informative for your audience. To ensure they know the content is coming from you, use a logo creator to design a logo you can use to brand your videos.
Brand Your Video
If you’re just starting to branch out into video, keep in mind that this content should also cohesively fit in with your established brand. This means maintaining your brand’s style of communication, including your brand voice and tone. Visual elements are also a must. Continue to use your brand’s color palette, use the same type of imagery you use in your image-based posts, and don’t forget to include your logo design somewhere in your video. This can be easy to include at the beginning of your video in an animated video intro or at the end in a transition or end card. This is super important because you want your audience to be able to relate your video content to your brand easily. If they watch your video, love it, but have no way of knowing who made it, then it won’t do much for you. Although it may seem simple, your color palette or your logo can make it super easy to attribute your video to you in less than a second, so definitely don’t skip this step.
Optimize Your Finished Video
When your video is shot, edited, and ready to be posted, there’s one more thing to consider: optimization. You want your video to be easy to find, and optimizing it will make that happen. On a platform like YouTube, for example, SEO can make a huge difference because it’s basically another search engine. This means you’ll have to step up your YouTube marketing by looking for keywords and include these in your video’s title, description, and tags. Don’t forget to include a CTA in your video and again in your video’s description so that it doesn’t get lost on your viewers. Of course, doing keyword research also helps keep you informed on what people are searching for, giving you even more ideas for future videos.
Beyond the written descriptions of your video, you will also want to make a thumbnail for it that will make it more enticing to viewers. Thumbnails give you a tiny space to work with, so do your best to make the most of it. Include a short title, an intriguing image, and throw in your logo so that people can recognize your content before they even click on it. It may sound like a lot, but getting the perfect balance can lead to more clicks.
Start Reaching Your Goals with Your Video Marketing Strategy
Now that you’re better equipped to create a killer video marketing strategy, what are you waiting for? Put your new knowledge to use and get the results you’re after. Keep in mind that this can take some time to master, so be sure to check on how your videos are performing so that you can make the necessary changes to your next videos. In no time, you’ll be a video master!
We have edited and prepared the video from SmashingConf Toronto, and it is all now live for you to watch and learn from. To get a feel for the event, watch our compilation. We think that it really captures the atmosphere of a SmashingConf!
Day One
The Day One Collaborative Doc created by attendees is full of takeaways from the first day of the conference. You might find some of those notes helpful as you watch the video linked below.
If you would like to be part of the SmashingConf fun next year, we already have tickets on sale for SmashingConf San Francisco 2020. The rest of this year’s events (New York and Freiburg) are already sold out! There are a few workshop-only tickets available for New York 2019, but be quick!
When you work in design for any length of time, forming habits is natural. It’s not unusual to follow a predictable process or use familiar patterns. This repetition can be fabulous for your productivity, but when each design looks much like your last, you can quickly begin to feel jaded. Staying curious is the best remedy for that feeling.
After running a small studio for eighteen years, my fatigue had become overwhelming. I dreaded each and every new email notification and phone call. While client projects offered opportunities to be creative, they also depleted my energy reserves and any capacity I had to come up with ideas.
For someone whose business — and self-esteem — relies on what I dream up, this was devastating. I admitted to my wife that I was exhausted, had no more to give, and couldn’t carry on because the business we’d started together had become a burden. I needed to recharge, reconnect with my creativity, and rekindle my enthusiasm for working in design.
When a company in Sydney offered me an interim role, I didn’t hesitate. They seemed welcoming, work was interesting, and living in Australia was something I wanted to experience. More importantly, time away allowed me to explore aspects of design which were new to me, away from the crushing pressures I’d felt building up while running my business.
Working in Australia meant finding creative ways to sell the company’s products and services, as well as exploring new approaches to the design of the products themselves. I was curious about whether graphic design and visual storytelling could make a digital product more compelling.
As I’d studied Fine Art and not art direction or graphic design, I knew very little about its principles, famous names, or history. I was eager to learn, and with the pressure of running my business lifted, I had the energy and the time for studying. I started a magazine collection, studied books on art direction and graphic design, and discovered art directors, including Alexey Brodovitch, Neville Brody, Bea Feitler, and Tom Wolsey. Their work fascinated me, and I was curious why we see so little like it online.
This curiosity took me in unexpected directions, and my head was soon bursting with ideas. I learned how to combine images and text in more exciting ways from Alexey Brodovitch and Bea Feitler. I picked up tips on how to give my typographic designs more impact from Neville Brody, and Tom Wolsey taught me how to make even the smallest design element more interesting. I studied editorial and magazine layout principles, and instead of merely copying them, I found ways to adapt them for the web to make product and website layouts more compelling.
Time away helped me rediscover my enthusiasm for design. While falling into predictable patterns — in behaviour and design — is still tempting, since coming home, I’ve realised how important it is to stay curious, study other media, and keep my mind open to the lessons we can learn from them.
Curiosity keeps a creative mind open to new possibilities, and that’s what Ernest Journal magazine — the inspiration for this issue — is all about.
Despite its smaller format, on my latest visit to my favourite magazine shop, I was drawn to Ernest Journal. Ernest is “a journal for enquiring minds. It’s made for those who value surprising and meandering journeys, fuelled by curiosity rather than adrenaline, and guided by chance encounters.”
When you open Ernest Journal for the first time, you’re immediately drawn to its content, rather than its design. There are beautiful photographs and striking graphic designs which are often presented large enough to spread from one page to the next.
The design of Ernest Journal is simple, but not minimal. It gets maximum value from only a small number of assets, in particular, its dominant two typefaces, Freight Big Pro and Gill Sans Nova.
Freight Big Pro is a high contrast serif typeface by Joshua Darden — the founder of type foundry Darden Studio — who also designed Jubilat and Omnes, two fonts I use regularly. Freight Big Pro is a family of twelve styles and comes with a host of OpenType features including beautiful ligatures, a feature used by Ernest Journal for headlines and even its logotype. While Gill Sans has never been a particular favourite of mine, the designers of Ernest Journal put it to good use in contemporary looking headlines and other typographic details.
Ernest Journal’s layout consists mainly of two and three columns, but it’s their thoughtful use, which helps the overall design feel connected, despite the variety of content and styles in the magazine. I’ll teach you how to create varied yet connected designs later in this issue.
Ernest Journal is an excellent example of how to use colour and typography to create consistency across an entire publication. At the same time, by picking colours from graphics and photographs to use for headlines, pull-quotes, and other details, their designers connect this overall design to individual stories. This adds variety and makes the stories Ernest Journal tells even more engaging.
Magazine Anatomy
The not-so-snappily named Web Hypertext Application Technology Working Group (WHATWG) surveyed thousands of websites before settling on names for new elements including header and footer. Magazines have their own terminology for parts of a page which you can use to name product or website components:
HTML
CSS
Running head
[role="banner"]
Folio
[role="contentinfo"]
Headline
.type-headline
Byline/credits
.type-credits
Standfirst (deck, intro, or kicker)
.type-standfirst
Lede
.type-lede
Image caption
—
Pull quote
—
Body copy
—
Sub-head
—
Next time you’re passing a magazine store, drop in and look for a copy of Ernest Journal. It might be small, but you’ll find it packed with ideas to use on your next project.
Inspired By Ernest Journal
Many people blame frameworks including Bootstrap for the homogenous layouts we see all too often on the web, but the problem comes from our thinking, not the framework. The cold, hard truth is that Bootstrap doesn’t create unimaginative designs. Lazy designers do.
The majority of Ernest Journal’s content is placed using a symmetrical grid which can easily be reproduced for the web using a framework’s twelve columns. Content is simply laid out using a mix of two and three columns. Yet unlike many websites built using a framework, Ernest Journal’s pages are exciting and varied. There’s no reason why frameworks can’t be used to create layouts as engaging as Ernest Journal. All it takes is an understanding of layout design and imagination.
Variety is a crucial part of the success of Ernest Journal’s design, and it’s a lesson we can apply to products and websites. Single columns have been used by book designers for generations and designs based on them look classical. Grids with two symmetrical columns feel orderly. They can hold a tremendous amount of content without becoming overwhelming. Combine white space with three or more columns and your designs immediately take on an editorial feel, reminiscent of a quality print publication, like Ernest Journal.
Designing With Frameworks
The original Fiat 500 was a tiny car which made a big impression on the motor industry. It was enormously popular and became the template for a generation of small cars. For this design about the rise of this iconic little car, I want to make a similarly big impression by filling a large panel with a headline and image. This panel occupies two-thirds the width of my page — eight of my twelve columns. The running text on the right occupies four columns, and its width is matched by the standfirst paragraph opposite, bringing this asymmetric composition into balance.
By using a variety of connected but diverse layouts, you can make stories more engaging and keep readers interested. My next design is based on that same twelve column grid but looks completely different. Here, the large image occupies six columns, half the width, and the full height of my page. Text runs down two columns in the centre, and supporting information — including a timeline of Fiat 500 models — matches its width, even though I place it within a much wider panel.
Now, I know some of you will be wondering how to adapt designs like this to smaller screens. Proportionately narrow columns of text don’t make sense when space is limited, so I use the entire screen width. Instead of asking people to flick past a tall image, I place the Fiat 500 on its side within a horizontal scrolling panel.
Even when using just two or three symmetrical columns, you can create a surprising variety of layouts. So that your design feels connected and familiar across all its pages, develop a system for how to use those columns. You might use three columns for running text, giving your design an editorial feel, and twin-columns for images.
Alternatively, use twin-columns of text for an orderly feeling and three columns for images. This increased repetition of shapes helps a composition to feel more dynamic.
Changing how you place images in three columns is a simple way to vary the look and feel of a design. My next design sets one large image across two-thirds of the page, and a small picture in the remaining third. But image proportions are not nearly as interesting as the position of the gutter between images, and how it offsets the gutter between running text columns below.
There’s still space on medium-size screens for an exciting juxtaposition of two and three columns. But what about small screens?
Twin-columns of running text would make no sense in such a narrow width, but you needn’t sacrifice the benefits of white space, even when it’s limited. For this small-screen design, I place images into a horizontally scrolling panel. Then, I use a narrow column to indent the running text.
Designing Connected Layouts
In the last issue, I introduced you to Swiss artist and typographer Karl Gerstner and the “mobile grid” he designed to lay out content in Capital magazine consistently and without restrictions. Those same principles apply when placing content inspired by Ernest Journal.
A single module — filling the entire width of the page — slows people down and encourages them to linger on its content. It isn’t necessary to use every pixel, and I devote a quarter of this composition to white space to give this design a feeling of luxury.
Something is reassuring about the structure of a twin-column layout, so for this design, I give equal space to these classic cars. To prevent this design from becoming predictable, I utilise extra columns for larger cars and use gutters to stagger the start of my headlines and paragraphs.
It’s possible to pump energy into the structure of a symmetrical three-column design. For this next design, I use those three columns in two different ways, first with a top-down view of the Fiat 500, then a smaller module for each of the remaining cars.
Designs which use odd numbers of columns and rows can be compelling, especially when arranged in a modular grid. This design demands attention not only because it‘s interesting visually, but also because it’s so different from other pages. It’s an excellent choice for interrupting the rhythm of reading to make someone focus on a particular piece of content.
Controlling Reading Rhythm
The pace in which someone moves through a product or website is an essential factor in their experience. This principle is as useful on a mobile’s smaller screen as it is on a larger one.
Slowest
Slower
Slow
Fast
Faster
Fastest
Creating Connections
One of the most attractive features of Ernest Journal, and a technique you can quickly adapt to the websites you design is using an accent colour picked from images. You can use accents for headlines, pull quotes, and other typographic and details to connect them with graphics and photographs.
Choose which elements to apply this accent colour and then style them throughout your website to create continuity. Use just one accent — or tints of that colour — per article to give each its own distinctive style.
On this first article, I pick a dark pink from the lights on the Fiat 500 and use it for my headline, standfirst, and dates in my timeline. For the second article, I sample a warm light brown from the suitcase in a photograph of another Fiat 500. There are plenty of tools available online to help you sample colours from images, but my favourite is still Adobe Color.
Using large blocks of colour can help you distinguish between content types, and choosing the same colour for panel backgrounds and typographic elements such as drop caps will maintain a subtle connection between them.
I use a warm dark brown for my drop cap, headline, and pull quote, and in the background of the panel which dominates these pages. The yellow outlines in the illustration, borders, and titles in the timeline is a colour I use to connect multiple pages.
For the second page, I also use the same light brown as before to create a palette of colours and consistency across all my designs.
Foundation Styles
Colours help create a signature style that can make a design memorable. Colour connects content to a brand, creates connections between images and text. They define the personality of a product or website, and ultimately an entire company, so it’s crucial to develop a suite of colours to use throughout your designs.
But colour isn’t the only aspect of a design which can help maintain that all-important consistency. You can create signature typographic elements, including block quotes, dates, and drop caps, as well as border styles, and image treatments which repeat across pages.
With these styles forming the foundation to your design, you’ll then be free to use colour and type variations to give each article its own unique look.
In this design, a background colour covers the entire page. Simply changing that colour between articles, while maintaining layout and typography styles, adds variety and creates a series of pages which, while different, feel like they belong together.
Using a tool like Adobe Color, experiment with analogous and complementary colours. Creating a colour family sampled from graphics and photographs, and using them in several combinations, is a simple way to create a variety of designs for sections across your website.
Ernest Journal’s design is successful because although each article has its own distinctive elements which connect the visual style with the content, those articles use a consistent grid system and foundation styles. This consistency helps Ernest Journal feel like a unified whole and not a collection of separate pieces.
NB: Smashing members have access to a beautifully designed PDF of Andy’s Inspired Design Decisions magazine and full code examples from this article.
We make use of state to keep track of application data. States change as users interact with an application. When this happens, we need to update the state that is displayed to the user, and we do this using React’s setState.
Since states are not meant to be updated directly (because React’s state has to be immutable), things can get really complicated as states become more complex. They become difficult to understand and follow.
This is where Immer comes in and that’s what we’re going to look at in this post. Using Immer, states can be simplified and much easier to follow. Immer makes use of something called “draft” which you can think of as the copy of your state, but not the state itself. It’s as though Immer hit CMD+C on the state and then cmd+V‘d it somewhere else where it can be safely viewed without disturbing the original copy. Any updates you need to make happen on the draft, and the parts of the current state that change on the draft is updated.
Let’s say your application’s state looks like this;
This user happens to be celebrating his 31st birthday and which means we need to update the age value. With Immer running behind the scenes, a replica of this state will be made.
Now imagine the replica is made and handed over to a messenger, who gives the newly copied version of the state to Kunle. It means there are now two copies available — the current state and the draft copy that was handed over. Kunle then changes the age on the draft to 31. The messenger then returns to the application with the draft, compares both versions, and only updates the age since that’s the only part of the draft that changed.
It does not break the idea of an immutable state, as the current state does not get updated directly. Immer basically makes it convenient to work with immutable state.
Let’s look at an example of this at work
Say you want to build a traffic light for your community, you can give it a shot using Immer for your state updates.
produce is the default function we get from Immer. Here, we pass it as a value to the setState() method. The produce function takes a function which accepts draft as an argument. It is inside this function that we can then set the draft copy with which we want to update our state.
If that looks complicated, there is another way to write this. First, we create a function.
We are passing the current state of the application, and the function which accepts draft as arguments to the produce function. To make use of this inside our component, we do this;
If you have been working with React for a while now, then you’re not a stranger to the spread operator. With Immer, you need not make use of the spread operator, especially when working with an array in your state.
Let’s explore that a little further by creating a shopping list application.
As items are added to the list, we need to update the state of the list to reflect those new items. To update the state of list using setState(), we’ll have to do this:
If you have to update multiple states in the application, you’ll have to do a ton of spreading to create a new state using the old state and the additional value. Which can look more complex as the number of changes increases. With Immer, it becomes very easy to do that, as we did in the example above.
What if we want to add a function that gets called as a callback after the state update?In this case, let’s say we are keeping a tally of the number of items in the list and the total price of all the items.
First, we create an object using the data entered by the user, which we then assign to newItem. To update our application’s state, we make use of .concat() which will return a new array that’s comprised of the previous items and the new item. This updated copy is now set as the value of draft.list, which can then be used by Immer to update the state of the application.
The callback function gets called after the state update. It’s important to note that it makes use of the updated state.
The function we want to call will look like this:
calculateAmount = (list) => {
let total = 0;
for (let i = 0; i < list.length; i++) {
total += parseInt(list[i].price, 10)
}
this.setState(
produce(draft => {
draft.totalAmount = total
})
)
}
Let’s look at Immer hooks
use-immer is a hook that allows you to manage state in your React application. Let’s see this in action using a classic counter example.
useImmer is similar to useState. The function returns the state and an updater function. When the component loads at first, the value of the state (which is count in this example), is the same as the value passed to useImmer. Using the updater function which is returned, we can then create an increment function to increase the value of the count.
useImmerReducer takes in a reducer function and the initial state, and it returns both state and the dispatch function. We can then loop through the state to display the items we have. We dispatch an action when submitting a todo item and clearing the list of them. The dispatched action has a type which we use in determining what to do in the reducer function.
In the reducer function, we make use of draft like we did before, instead of state. With that, we have a convenient way of manipulating the state of our application.
You can find the code used in the above example on GitHub.
That’s a look at Immer!
Going forward, you can begin to make use of Immer in your next project, or even slowly begin to use it in the current project you’re working on. It has proven to aid in making state management convenient.