Archive

Archive for October, 2016

Cinemagraphs in web design

October 24th, 2016 No comments

If you read any of the countless web design trend reports that came out earlier this year, you likely read about the promise of large, hero-sized cinemagraphs placed prominently on homepages everywhere. So where are they?

While a few fashion-forward companies are using them on their websites, the cinemagraph has been largely relegated to showcase round-up articles and reddit pages.

Well I say enough is enough. It’s time that cinemagraphs rise up and take their proper place as the web page heros they were destined to become.

Why cinemagraphs work

The idea of following a web design trend simply because it was forecasted never really excited me. But what if you could actually pioneer such a trend? And what if it actually had a purpose, and solved a problem at the same time?

The human eye loves motion.

When it comes to cinemagraphs, all of the above statements are true. While it has certainly been discussed, (and even forecasted as a trend in web design,) very few websites are actually using them. As a result, they haven’t even come close to reaching a critical mass, so they are still mesmerizing to most web users.

Not quite a photograph, not quite a video, cinemagraphs are inherent eye-candy because they fool the viewer just long enough to make them take a second look. In the A.D.D. era we live in today, anything you can use to make a user pause — even for just an instant — counts as a small win for one very important reason:

You’ve got their attention.

One particularly effective way of attracting a bit of attention on a website has always been video. The human eye loves motion. But a large hero video (even a short one) is so bulky. Sure you can compress it within an inch of its life, but then it just looks… compressed. Or you can leave it alone and suffer the consequences of a slow-loading web page.

But by using a cinemagraph, you can save a lot of bandwidth while still satisfying that need for motion. Actually, you’re upping the ante, because you can capitalize on the novelty aspect of a cinemagraph — People just don’t see them very often, and are impressed when they do.

So now that you know why cinemagraphs deserve a place of importance on the web, let’s take a high-level view of how to bring one to life.

Glendevon Motors uses a cinemagraph in its hero area to convey a mood and stand out as a “premium brand” amongst its competitors.

Option 1: use a pre-existing cinemagraph

There are many instances when sourcing a ready-made CG is acceptable, or even preferred to making your own. I’d say that if you can find what you need, and it’s in your budget to get the rights to it, then that’s the way to go. The only question is: where do you find it?

The good news is, you’ve got options. They will be largely determined by your budget, (or your client’s,) but there are many sources out there. There are even a few free ones to choose from. However, if you have eighty bucks to spend, Shutterstock has a pretty decent selection of high-definition CGs.

(Tip: They don’t have a stand-alone cinemagraph section, so you just have to search for the term “cinemagraph,” plus your other search terms within the “footage” section.)

If you manage to find what you were envisioning, you’ll probably still want to compress the file to a certain degree. More on that in a bit.

Option 2: Make Your Own

The whole point of using a CG instead of a video is that it is meant to be a bit of a mind-trick.

Maybe you couldn’t find what you had pictured. Or maybe you’re just a die-hard DIY’er, and I respect you for it. So how exactly does one make a cinemagraph from scratch?

First, it helps to have the right equipment and a plan. Here is what I recommend to get started:

  • A camera that can shoot video
  • A tripod
  • A model and/or any necessary props
  • A computer
  • Access to a video editing program (optional)
  • Access to Adobe Photoshop or a more dedicated cinemagraph editing software, such as flixel

That is what you’ll need in order to make a cinemagraph. But in order to make it effective, you’ll need a great idea.

What Makes a Great Hero Cinemagraph?

While the general theme of your CG will be largely dictated by the niche of the website itself, there are certain universal points to keep in mind when setting the scene. Be sure to:

  • Keep it subtle: The whole point of using a CG instead of a video is that it is meant to be a bit of a mind-trick. Some of the best CGs look very still, then surprise the viewer with a subtle motion. Speaking of subtlety, make sure the overall composition isn’t overly busy or brightly colored if you are layering text and a CTA on top of it. Remember, the CG should play off those elements, not distract from them. Speaking of which…
  • Leave room for the real hero: Make sure you know where you want your headline, subheader and CTA button to go within the cinemagraph. This will affect where you place the main action in the composition.
  • Keep it anchored: Of course, a CG has some motion, but the scene overall needs to be very still to properly contrast the movement. A tripod should help with background movement and camera stability. If your model’s eyes are meant to move from side to side, make sure she keeps her head very still at the same time.
  • Make it loop-able: Since you want the file to be relatively small, you will need to loop the action so it repeats as seamlessly as possible. Plan for this when setting the scene. Ideally, the first position should very closely match the final position, closing the loop.
  • Use a person if possible: Studies have shown that images with people in them keep people’s attention much more than ones that don’t. This also holds true for CGs. Extra points if you can manage to have your model looking in the direction of the CTA. This has been shown to draw the user’s eye there as well.

Once you have all your elements in place, try to shoot about 20-30 seconds of video, repeating the desired motion several times, with about 5 seconds of keeping things completely still in between. This should give you enough raw footage to turn into an eye-catching cinemagraph.

Putting it together

While I won’t go onto the step-by-step process of turning a video into a cinemagraph, there are several options available to you. You can shell out $299 to use a dedicated cinemagraph design program, but you can put a nice CG together using Photoshop, (which I’m guessing you already use.)

Compressing the file

Whether you made your CG from scratch, or sourced an existing one, you want to make sure it loads quickly. Whether your final output file is a gif or video (which I recommend,) your compression will rely on two separate factors:

  1. Quality
  2. Length

Personally, I try to go for the highest quality possible in any large format hero image, video or cinemagraph. In my opinion, sacrificing the quality of any file that is meant to make such a visual impact is a shame. In order to balance this out, I try to make my cinemagraph loop as short as humanly possible.

The action will have an effect on how short the loop can be — a train buzzing by can be much shorter than a slow, deliberate eye glance, which might look somewhat spastic if it repeated too quickly. Take the below example from web agency The Deep End. Since all that is needed here is for one train car to match the next in order for a pretty seamless loop, I managed to cut it down to around one second.

Even though I managed to keep the action extremely succinct, I still knew the file size could be reduced for an even quicker load. I ended up using a free online video compressor called ClipChamp. I was able to compress the video down from several megabytes to a svelte 319 KB. Remember, most users will bounce from your site after only three seconds of waiting, so it pays to be quick.

And if your end result is left with artifacts from extreme compression, you can always employ a tried and true trick used on imperfect hero videos — mask it with a semi-transparent patterned overlay.

Interested in seeing how others have used cinemagraphs as hero images? I’ve got some good news, and bad — There aren’t too many more to show, which is the bad news. But the good news is, if you were to put this plan into action, you would be on the vanguard of what promises to be a pretty big trend.

Here are a couple that I managed to find around the web:

Gilt Taste

gilt-cinemagraph

The Nature Conservancy

Final thoughts

A cinemagraph can not only kick an otherwise boring website project up a few notches, but it can actually impact its success too. If you combine it with a killer headline and compelling call-to-action, you can really grab your users’ attention. What you do with that attention is up to you.

Bundle: 110+ UI Screen Templates with 1000 UI Components – only $21!

Source

Categories: Designing, Others Tags:

How To Poison The Mobile User

October 24th, 2016 No comments

One of the most popular children’s television heroes here in the Czech Republic is The Little Mole, an innocent, speechless and cheerful creature who helps other animals in the forest.

TV heroes often fight against people who destroy their natural environment. When watching The Little Mole with my kids, I sometimes picture him as a mobile website user. Do you want to know why?

The post How To Poison The Mobile User appeared first on Smashing Magazine.

Categories: Others Tags:

The Best WordPress Hosting: Shared, vServer, Cloud or Managed?

October 24th, 2016 No comments
it-838384_640

Those that want to have an own WordPress website which they have 100 percent control over, need a WordPress hosting. But there are so many options, which one should you pick? On top of that, it’s possible to get excellent solutions in every area. All of these solutions have advantages and disadvantages. Today, we’ll guide you through the jungle of WordPress hosting.

WordPress works with virtually all options that Hosting can offer. So basically, it’s a decision that you have to make based on a forecast for your future. Of course, a website on a good dedicated server will most likely be delivered the fastest, but you would have to be able to administer that kind of server.

The planned website purpose is also something to consider. Will it be a personal blog or a very extensive online shop that wants to gain lots of visitors with an ad budget?

Thus, you should ask yourself: what type of website do I want to have, and how many visitors will I expect in the beginning? After you’ve done this, there are the following options to choose from:

1 – Shared-Hosting: for Beginners

A shared hosting means that you will share one server with a lot of other customers.

childhood-84554_1280

That doesn’t have to be a bad thing. It can prove to be a good solution for beginners and websites that don’t expect a lot of visitor traffic. Shared hosting is very affordable, and some providers provide good equipment as well. When all you want it a personal blog or a website for your wedding, shared hosting will work well for you. However, it might also have very significant disadvantages.

Pro:

Very inexpensive. A decent package with SSD and PHP7 is available starting from about 5,99 Euro a month. 96 MB PHP memory limit, as well as two domains, are included as well.

You won’t need to take care of the server’s security, and the majority of things you’ll need is already installed. If you happen to have any problems, just contact the support of the host.

Con:

On some shared servers, the resources divide between hundreds of people. When one of the other websites is attacked, or gets a lot of traffic, your website will also come to its knees. When one website uses up more resources than planned, the others will suffer from that.

Additionally, there are only very few, excellent hosts that care for the speed and security of all websites on the shared server. Your access to resources and settings are also very limited.

  • Recommendable for: Beginners and Low-Budget Projects
  • Up to How Much Traffic: From my experience, a good shared hosting can handle 20,000 visitors a month.

2 – A vServer: for Advanced Users

So-called vServers are virtual servers. All this means is that it’s a massively enhanced shared hosting. You still share one server with other sites, but on vServers, there are fewer websites on one physical machine. A real, physical server splits into virtual servers using software. As these virtual servers are divided via software, you have an area with guaranteed resources that you won’t need to share with others.

server-90389_640-w550

In this section, there are two types of servers: a so-called managed vServer, and a “regular,” unmanaged vServer. The managed version is administered and secured by the host. The host also provides all tools that you may require for the creation and management of your website(s).

A proper vServer is capable of handling quite a bit of traffic. When your website is growing, and expecting a couple of thousands of visitors each month, a vServer is the right choice for you. It is also possible to execute scripts with a virtual server.

Pro:

You’ll get a much larger piece of the pie, and have some guaranteed resources. Your website won’t suffer from other sites being attacked or getting a lot of traffic. In a managed version, your host will take care of server security while providing all tools needed to manage your server.

On top of that, you have a lot more settings options, allowing you to decide what the server’s most critical parameters should look like. Php version, the right PHP memory limit, as well as other things can now be customized.

Con:

If you didn’t pick the more expensive managed version, you are responsible for the security, and the software for the management and creation of a website, as well as the server settings. If you don’t have any knowledge on servers and their administration, a vServer would be a bad choice. Additionally, an unmanaged server barely has any access to good host support.

  • Price: A decent vServer is available from about 18 Euro a month.
  • Recommendable for: Advanced, and server experts. Those lacking server knowledge are better off choosing a managed vServer and spend more money.
  • Up to How Much Traffic: From my experience, it can easily take on 100,000 visitors a month, as long as a proper variant is chosen

3 – Managed-Root Cloud Server: Future-proof

A managed root cloud server is an intelligent choice, and also future-proof. It’s a vServer as well, but with a couple of really substantial advantages. Firstly, it’s managed and provided with support. Secondly, the guaranteed resources aren’t static. If an ordinary vServer isn’t enough anymore, you have to choose a different product, and spend a lot more money than potentially necessary. On top of that, you would then have to move the website.

On this vServer variant, you are guaranteed access to individual resources that are always there. If these resources were to run out, altering the benchmark data in the server management would not be a problem. More ram, more CPU power, or a larger SSD? No problem, it’ll be done in seconds.

You only have to pay what you need. If you need more, it’ll naturally become more expensive. However, you can easily assign the amount of power to yourself that you need. This could be important should you receive more visitors than usual for a short amount of time. Quickly drive up the resources, and you’re good. Once the flood of visitors dies down, move the performance back down. The required payment will be exact to the second.

Pro:

A low price allows for easy entrance. The product is fully scaleable and adjusts to your requirements. You don’t need to take care of the security; your host will do that. Payment is exact to the second, making the monthly costs easily calculatable. An auto-installer guarantees fast installation of the most popular content management systems.

Con:

If the traffic stays high consistently, the price structure is not worth it anymore. Here, you’ll have to compare whether it would make more sense to switch to a dedicated server, considering both price and performance.

  • Price: Starting from 0,02 Euro an hour or 14,40 Euro a month. Of course, costs will be higher with increased resources.
  • Recommendable for: Far-seeing people that either can’t or don’t want to take care of the server administration. This version is future-proof to an extent.
  • Up to How Much Traffic: Even the smaller variant of the managed root cloud server is easily capable of handling more than 100,000 visitors each month. Half a million should also be manageable by increasing the resources without the price becoming too high.

4 – Managed WordPress Hosting: The Comfortable Solution

This interesting, but more expensive option is often overlooked, which is why I’ll briefly present it here. Managed WordPress hosting also describes a hosting on a vServer, but on a very small one, in this case. Only one website can be hosted on this variant. In return, you won’t have to take care of anything at all.

comfortable

The service team will even relocate your website for you. They’ll secure your small vServer, save your WordPress core files, and make sure that your WordPress always receives the newest updates. If you want to, they’ll even keep your plugins and themes up to date.

You also won’t have to worry about the quick delivery of your website, as the hoster’s technicians will do that instead. All you need to worry about is the content of your site.

Pro:

Pretty much every task will be taken off you, you won’t need to worry about anything. Absolute feel good hosting. The German provider I know, Raidboxes, uses SSDs, HTTP2, PHP7, nginx instead of Apache, and a server-side caching. This makes for rapid websites.

Con:

Only a single website can be hosted, and every additional one will cost you the same amount of money on top of the other price. You are not able to influence anything, and you have to take everything the way you get it.

  • Price: A decent package starts at 17,85 Euro a month including German VAT.
  • Recommendable for: People that don’t want to take care of anything but still want to have a fast website.
  • Up to How Much Traffic: I don’t have any experience with this. If you’re interested, please contact the Raidboxes support.

5 – Dedicated Server: for Experts

Here’s where things get professional. A dedicated server is something you can touch. A full-fledged device that you don’t have to share with anyone. It’s up to you to decide if your website has a very high monthly user drive, and page views that make the competition cry in envy.

trusttheexpert

However, you are fully responsible for the security, set up, the operating system, and the tuning. If you are not a server expert, this is not the choice for you. You also need to thoroughly think about the choice of your own server, as usually, you will have to live with the available resources, and can’t push them up easily. There are servers in every performance class, so you should inform yourself about, and compare what is provided.

It’s also important to know whether you have any right to claim a certain support given the price you pay.

Pro:

You’ll get an own device and won’t have to share the performance with other. You get to install any operating system you want to, and any version of additional software. For instance, you could use Nginx instead of Apache, or install HTTP2. The newest PHP version is not a big deal either, as you get to influence every tiny detail. Websites on a proper server usually run well and have enough power for lots of traffic.

Con:

You are responsible for everything, and you have to take care of it. You need to manage the server all on your own, including everything that this comes with. The operating system, admin interface, security, tuning, additional software – all of this has to be provided and kept up to date by yourself. If you don’t do it, the server will be vulnerable.

  • Price: A proper server with future security starts at 130 Euro a month.
  • Recommendable for: When you speak Linux, and think in console commands, this is the right choice for you. It would also be a good pick for resellers and agencies that want to host their customer websites themselves.
  • Up to How Much Traffic: Starting from 300,000 visitors a month. But even a dedicated server is not capable of handling an infinite amount of traffic.

My Recommendation for You

I recommend the managed root cloud server. It is still rather cheap and an investment into the future. On top of that, the security, the operating system, new software, and everything else is done and provided by the host. However, with a bit of technological knowledge, you can still do a lot yourself, as you have full root access. Using SSD, HTTP2, and PHP7 allows for real website power. Install Nginx on top of that, and it should be easy to realize websites that load somewhere near 300 milliseconds.

This Was a Short Look Into the Right Hosting

Of course, I’m not able to go in-depth in such an article, but the advantages and disadvantages should be clear now. All of my experiences of over ten years of web hosting have been put into this article. All traffic information was given from my experience.

Hosting doesn’t stop with a dedicated server, as even after that, there are plenty of options like managed cluster servers. However, these are only worth it for websites like the Smashing Magazine, which was able to overload its servers on a regular basis in the past.

Categories: Others Tags:

The Thick Standard – Bold Business Cards with Painted Edges Giveaway

October 24th, 2016 No comments
painted-edges-business-cards
We’re excited to collaborate with the innovators in print, Jukebox, for an amazing giveaway!

FIVE winners will receive 500 ultra thick business cards with painted edges – What better way to show off your personal style than with the coolest business cards!?

Read more…

Categories: Designing, Others Tags:

Why Do Websites Publish AMP Pages?

October 23rd, 2016 No comments

I cannot tell if you AMP will shake out to have been a good or bad idea for the web.

I can attempt to answer this question though: those sites don’t care where you read them. They just want people to read them. Read them. Like them. Trust them. So when they have something to sell (in any sense of the word), they sell it. Losing that attention is more scary than losing direct traffic to one place it publishes. Without saying it in so many words, AMP is saying: you stand to lose that attention without this.

And of course it’s not just AMP, there are loads of off-site places you can publish to. So many that I think publishers are saying: “whatever, just make it easy, and we’ll blast our content wherever you want.”

Direct Link to ArticlePermalink


Why Do Websites Publish AMP Pages? is a post from CSS-Tricks

Categories: Designing, Others Tags:

Popular design news of the week: October 17, 2016 – October 23, 2016

October 23rd, 2016 No comments

Every week users submit a lot of interesting stuff on our sister site Webdesigner News, highlighting great content from around the web that can be of interest to web designers.

The best way to keep track of all the great stories and news being posted is simply to check out the Webdesigner News site, however, in case you missed some here’s a quick and useful compilation of the most popular designer news that we curated from the past week.

Note that this is only a very small selection of the links that were posted, so don’t miss out and subscribe to our newsletter and follow the site daily for all the news.

10 Best New Web Design Tools for October 2016 – Creative Blog

8 Ways to Become More Creative in the Next 10 Minutes

The Art of Meaningful UX Design

Black – A Wallpaper Series Using Shapes and Lights

Inspiring, Simple Color Palettes

5 Top Landing Page Mistakes

Top Trending Tools for Designers

Product Design Inspired UX Design

7 UX Design Trends to Watch Out for in 2017

How the Web Became Unreadable

The Redesigned Vimeo Wants to Be LinkedIn for Indie Filmmakers

A Movie Poster Every Day for a Year

Leaked Email Shows What Wendy Clark Wanted in Hillary Clinton’s Campaign Logo

How One Illustrator Eliminated the Need to Hunt for New Clients

Line Maker: Animated Decorative Lines

Tobias Van Schneider — How to Find your Perfect Color Pairings

The Average Web Page – From Top Twenty Google Results

2016 Material Design Awards

7 Ways to Come up with Creative Ideas, Backed by Psychology

Materialette – A Color Palette for Material Design on OSX

New Pandora Logo Vs. New PayPal Logo

The 40-Year-Old Logo America Really Needs Right Now

User Onboarding: A Comprehensive Guide

The End of the Black Turtleneck

Art History: Frida Kahlo and her Influence on Graphic Design

Want more? No problem! Keep track of top design news from around the web with Webdesigner News.

LAST DAY: 100 Colorful Grunge Textures from Florin Gorgan – only $12!

Source

Categories: Designing, Others Tags:

You Can’t Detect A Touchscreen

October 22nd, 2016 No comments

Stu Cox explains that there are a ton of ways you might think you can get a yes-or-no answer on whether a browser supports touch or not:

  • Width media queries
  • Touch-related DOM events
  • Touch-related APIs
  • Pointer media queries

The normal refrain around this is “there are devices that are both, so you’d be wrong on those,” which is true, but it’s actually more problematic than that. These testing methods are often just straight up wrong.

So:

For layouts, assume everyone has a touchscreen. Mouse users can use large UI controls much more easily than touch users can use small ones. The same goes for hover states.

For events and interactions, assume anyone may have a touchscreen. Implement keyboard, mouse and touch interactions alongside each other, ensuring none block each other.

Direct Link to ArticlePermalink


You Can’t Detect A Touchscreen is a post from CSS-Tricks

Categories: Designing, Others Tags:

How To Transform Your Next Conference Takeaways Into Real-Life Results

October 22nd, 2016 No comments

Editor’s note: So you’ve attended a conference, listened to some truly inspiring talks, made quite a few valuable connections, maybe even attended a hands-on workshop and learned a thing or two. What now? How do you bring back the new knowledge and ideas and connections to your team and to your work? This article highlights a practical strategy of getting there without much effort. With SmashingConf Barcelona taking place next week, we thought this article would come in handy.

Have you ever been to a conference with top speakers, awesome people to network with and such a great energy that you got fired up and couldn’t wait to get home to start applying everything you’ve learned? How do things look two weeks later? Did you implement all of that learning into action? How about two months later? Were you still taking action on that knowledge?

The post How To Transform Your Next Conference Takeaways Into Real-Life Results appeared first on Smashing Magazine.

Categories: Others Tags:

Comics of the week #362

October 22nd, 2016 No comments

Every week we feature a set of comics created exclusively for WDD.

The content revolves around web design, blogging and funny situations that we encounter in our daily lives as designers.

These great cartoons are created by Jerry King, an award-winning cartoonist who’s one of the most published, prolific and versatile cartoonists in the world today.

So for a few moments, take a break from your daily routine, have a laugh and enjoy these funny cartoons.

Feel free to leave your comments and suggestions below as well as any related stories of your own…

Poor computer

Save a buck

TMI

Can you relate to these situations? Please share your funny stories and comments below…

14 Unique Fonts in TT Cottons from TYPETYPE – only $9!

Source

Categories: Designing, Others Tags:

On Style Maintenance

October 21st, 2016 No comments

I was talking to a brilliant engineer friend the other day who mentioned they never get to build anything from the ground up. Their entire career has consisted of maintaining other people’s (often quite poor) code.

In a perfect world, we’d all get to write code from scratch, it would work perfectly, and we would put it into a bin in the sky, never to be looked at by anyone again.

We all know that’s not how it works. Code need to be maintained.

Kyle Simpson often begins his talks explaining that we spend only 30% of our time writing code, and 70% of our time maintaining it. Being a good coworker and programmer is not just about being a skillful problem solver, but being legible. Great developers produce code with maintenance in mind.

I often joke that I don’t want to hire a code ninja. Ninjas come in the middle of the night and leave a bloody mess.

I want a code janitor. Someone who walks the hallways of code, cleaning up pieces, dusting up neglected parts, shinning up others, tossing unnecessary bits. I prefer this gentler, more accurate analogy. This is the person you want on your team. This is a person you want in your code reviews.

Shoutout to JD Cantrell, who is an awesome code janitor and code reviewer.

Let’s think about code maintenance through the lens of two different programming paradigms

In programming there are many tools and procedures available to meet the same end. There is no right answer. Here is a succinct definition by Michael Feather of two very popular programming paradigms:

Object-Oriented Programming makes code understandable by encapsulating moving parts…

Functional Programming makes code understandable by minimizing moving parts.

Let’s consider both in terms of not just understandability but also maintenance.

Functional Programming

I have seen for myself the value of using a functional approach in front-end JavaScript. When we write code, sometimes we want to assume that it will be used forever the way we intended, but most of us have been doing this long enough now to acknowledge that that isn’t always the case.

Functional programming includes, but is not limited to:

  • It is declarative – we’re writing in a way that can be reused and not telling the computer exactly what you need it to do at every step. This shares some similarities with abstraction.
  • It is pure – we’re not modifying or changing things outside of the function’s scope, and for this reason…
  • It is Immutable – you won’t get into a situation where you feed it the same value and retrieve different results on multiple executions.

I believe functional programming can be extremely useful in terms of maintenance because of the lack of side effects. This is huge. This keeps our code from becoming brittle. People sometimes think the biggest problem is errors in our code. I’d argue that the worst code isn’t code that errors out and fails. We can track down with methodical isolation. The worst code is code that behaves a way that you can’t predict, quietly, all over the place. You run around the code base playing whack-a-mole and sometimes it’s difficult to find the culprit. A functional programming style takes on this problem preemptively, because it’s built from the ground up to keep this from happening (as much).

Here are some resources if you’d like to dig deeper into functional programming:

As much as I’m in love with functional programming, please be aware that there can still be issues with maintenance. If a few things use the same pure function, and over time you adjust that function for one of its applications, you can get into a problem where you’re also altering other things that are hidden dependencies. Good documentation is really helpful here.

Object-Oriented Programming

In contrast, Object-Oriented Programming is a little more like following the steps to a recipe. It uses objects, which may or may not contain data, and methods, which tends to be procedural. Typically objects have an idea of self (e.g. “this” in JavaScript). Object-Orientation doesn’t focus on purity, but rather, tends to use encapsulation to make sure nothing leaks into outer scope.

At it’s best, Object-Oriented approaches tend to think of the highest order of something, then pares down to each type of instance you can have, breaking out what to do in each case. If you’re thinking about it like the Linnean System of Classification for animals and how we’d make Morphology Trees (who wouldn’t? :)) You’d start by asking is it warm-blooded? Then, does it have fur? Then does it have a snout? etc. I’m really butchering biology here, but it’s an example.

At it’s worst, Object-Oriented programming gets a lot of pretty necessary criticism because sometimes you’re not clearly describing what you think you’re describing. You can think of this like: you think something’s a banana but really it’s a peach because the only thing that’s described to you is that you have a fruit. We talked a little bit before about how that kind of code can be a nightmare to maintain, so while that’s not always the case, it can certainly come up.

An applicable example in CSS

With both functional and object-oriented approaches in our minds, let’s consider how that applies to CSS and the concept of authoring versus maintenance. CSS is written declaratively and purely. You can’t mutate one CSS block using another CSS block.

I think a lot of people would anticipate that a purely functional approach would be best for CSS. They might associate that with keeping CSS as pure as possible, which is where ideas like CSS Modules come from. The concept is that if you encapsulate the styles for the thing you’re modifying them right where you need them. You’re only ever dealing with that instance. No side effects. I don’t disagree. You avoid a few things this way.

  • You avoid collisions. This is where object-oriented programming gets a bad rap for sometimes.
  • You avoid naming. Naming is hard. You can avoid naming with this approach.
  • You avoid dealing with the cascade. I’ll address this in a minute.

For other kinds of (non-CSS) programming, we keep things pure and avoid global scope and we’re golden! So it must apply everywhere, right?

Here’s where we need to get into the right tool for the job. If we’re considering maintenance over writing, here is where other approaches shine:

  • Companies big and small tend to have redesigns at least every 1-2 years. If your code base is large, with many people, and you need to change the line-height everywhere from 1.1rem to 1.2rem, are you having to go back into every module and change that value? A global or an object that’s extended becomes extraordinarily useful here.
  • The cascade can help, if you understand and organize it. This is the same as any sophisticated software design. You can look at what you’re building and make responsible decisions on your build and design. You decide what can be at a top-level and needs to be inherited by other, smaller, pieces. This avoids spaghetti code in CSS and keeps your code DRY.
  • CSS is about design. Good design, is by it’s nature, successful when it’s cohesive. A CSS codebase that aligns itself with the design infrastructure it’s built from allows for cleaner code, with the added benefit of better collaboration. CSS can be self-checking for designers as well: “Wait we have another tertiary button? Why?” Leaks in cohesive UI/UX announce themselves well in this model.
  • Naming can help with documentation. This point is a little more prickly, and I’m not sure totally necessary, but worth mentioning. Whether you like BEM, or SMACSS/OOCSS, or Atomic, naming when done well can actually give you good information on where a class is used and why.

The paradigms share traits

As you might suspect, though I see value in other paradigms, my preference is a functional style. With that in mind, you might wonder why I would find value in an Object-Oriented approach to CSS.

Despite it’s name, OOCSS shares traits with Functional Programming. To correctly work with OOCSS the way it was intended, you’re mostly creating mixins that are expressed similarly to functions with parameters (often with defaults) across your system. They are pure, and can be applied to multiple uses.

It still uses Object-Oriented approaches as well. With a very intelligent architecture built with anticipation of how things might be affected by each other, and carefully considering what should be inherited. Considering that CSS is fundamentally a group of objects, this tends to make more sense in a CSS context than in other languages.

Last year I lead a team to completely refactor a giant Front-End component system. It used an OOCSS architecture, I and saw for myself the benefit of this type of model. Designers could ask me to modify something, and we could quickly see it update across the site. They could even change their minds without too much of a hassle. A last minute request from above did not stall our release. I’m definitely not saying it wasn’t without it’s pain points- but it was surprisingly smooth for it’s scale. This has made me look at the way I write CSS for other applications in a whole new light.

Future-forward

People tend to pit these things against each other:

  • CSS
  • Styling via JavaScript

I would argue that you can be maintenance friendly or create a maintenance nightmare either way.

You can absolutely deal with things like line-heights, fonts, and behaviors responsibly in Aphrodite, or React-CXS, or CSS Modules. I quite like some of these approaches. They can handle inheritance, and be written to extend for a DRY-er and more maintainable approach.

But even though you can, I personally haven’t seen enough examples of projects that do. (I’d love to see some examples!)

Mostly I see people pull out a variable or two for the brand color and nothing else. A few variables does not a responsible system architecture make. I think we can do better here, if we think about our code not in terms of what is easier to write, but what’s easier to change. Or better yet, in terms of what’s easier for others to change.

Please also take care to create good documentation! With either programming paradigm, you have to know about all of your dependencies before you adjust it. Great documentation also means you are more purposeful in your decision-making as well. There are less “oh well”s when you have to explain what a thing is and where it’s used to other people.

The issues I’m tackling in this article are issues of collaboration and scale. Not every company or site or even web app is tackling these things. This is an opinion article that comes from experience. Different things work for different projects.

My hope for this article is to encourage developers to think ahead. We’re all in this together, and the best we can do is learn from one another. If you completely disagree with me, that’s totally fine. My hope is that even in taking a stance, you might solidify a direction you head towards with maintenance as the core concept.


On Style Maintenance is a post from CSS-Tricks

Categories: Designing, Others Tags: