Delivering WordPress in 7KB

Post pobrano z: Delivering WordPress in 7KB

Over the past six months, I’ve become increasingly interested in the topic of web sustainability. The carbon footprint of the Internet was not something I used to give much thought to, which is surprising considering my interest in environmental issues and the fact that my profession is web-based.

The web in a warming world

As a brief recap, I attended MozFest in London last year. In between sessions, I was scanning a noticeboard to see what was coming up, and I spotted a session entitled, „Building a Planet-Friendly Web.” I felt a little dumbstruck. What on Earth was this going to be about?

I attended the session and the scales fell from my eyes. In what now seems obvious — but at the time was a revelation — I learned of the colossal energy demand of the Internet. This demand makes it the largest coal-fired machine on Earth, meaning that its CO₂ emissions are probably at least equivalent to global air travel. More and more people are coming online, but this, coupled with the rise of ever more obese websites, means that the Internet’s energy demands are growing exponentially. Every additional byte transferred means more energy, which in most countries means more CO₂.

It is widely accepted that we should avoid printing emails to save trees, but this leads to a false assumption that the web is a green medium. I’m afraid to say, it is not.

Is there another way?

The good news is, it needn’t be this way. Since 2009, Greenpeace has been auditing Internet companies on their energy usage, and lobbying them to improve by way of their Clicking Clean campaign. The Green Web Foundation has an ever-growing database of hosting companies who use renewable energy, or who are at least committed to being carbon neutral. And new tools are emerging to help those working on the web measure the environmental impact of our products.

There are also some great resources out there such as Tim Frick’s Designing for Sustainability, three year’s worth of talks from the SustainableUX conference, and peripheral material that, while not explicitly focused on sustainability, can help us build lower carbon websites.

Enter Susty WP

I decided to challenge myself to see how efficiently I could package a WordPress website. While I was at it, I thought, “Why not make the website about sustainability and WordPress?” I know, WordPress/sustainability inception. Cool, huh?

And so, sustywp.com is born. With its accompanying theme, Susty. I’m rather chuffed to say I managed to get the load of the homepage down to 7KB of data transfer. I did actually get it down to 6KB, but the meta stuff added by Yoast bumped it up almost a whole KB! 😛 However, given I’m trying to spread a message, I deemed this to be an acceptable trade-off.

Before I get into the nuts and bolts, I just want to share a few headline facts:

So, how does it work?

The remarkable thing about this is actually how mundane it is. Heavily inspired by Heydon Pickering’s evangelizing about writing less damn code, and projects like Brad Frost’s Death to Bullshit, I embarked on a root and branch pruning of Underscores, removing everything I possibly could. And to be clear, it’s not as though Underscores is full of cruft. It’s a very lean starting point for building a theme. I’m a great admirer of it and thoroughly endorse using it. However, it includes certain assumptions that didn’t chime with my spartan goal of making the smallest possible WordPress site.

Such as, you ask?

Nav? No. Sidebar? Get rid of it. Classes? Not in my socialist utopia.

Given the constraints I had set, anything making it to the DOM had to have a very good reason to be there. With this being an experiment, I took the somewhat radical approach of relegating the navigation to its own page. This is wonderfully liberating and means I didn’t have to go through the almost always disappointing dance of wondering how I would make it look presentable, hide it for the many users who won’t care, make sure it’s robust enough to be infinitely long with never-ending dropdowns, etc.

This means less HTML, less CSS, and definitely no JavaScript! Win, win, win.

As for the sidebar? Well I’ve always had an aversion to sidebars, so that was an easy thing to remove. Susty has no widget area. I’m sure it’ll get over it.

Is there more fat we can trim? Well, if we’re going to have hardly any HTML, and we want minimal CSS, do we really need all those classes? I wanted to try my hand at writing CSS in the way it was intended to be used, instead of bowing to the class-ititis and div-ititis that pervade the industry.

You might not need web fonts

Alongside images, video and JavaScript, the other item that has become a significant factor in bloated websites is web fonts. Given that it’s now a Silicon Valley fashion for every startup to commission its own typeface as a first order of business, it seems as though every website you visit incurs downloading a bunch of font files. It may not seem so bad to tack on a hundred kilobytes for some nice type, but when you multiply this by the many different people visiting your website across different devices and browsers, fonts can easily account for hundreds of megabytes of data transfer — if not gigabytes/terabytes/petabytes for higher traffic websites.
Custom web fonts are also a potential antipattern for our users, for whom:

  1. Page loads are slowed down as they see either a flash of unstyled text or, potentially even worse, no text while the font loads.
  2. By the time the font has loaded, they don’t notice or care.

If you do have to use custom fonts or are in combat with the flash of un-styled text, font-display is an new property designed to instruct the browser how to handle font downloads. This post goes into it even more.

Almost every device these days has a half-decent set of fonts installed, so why not compose a stack of potential fonts you’d like to see, ending with either “serif “ or “sans-serif.” Or embrace those default fonts altogether with a system font stack.

I wanted Susty to have a bit of a Swiss Style aesthetic, so my font stack ranges from the perfectly proportioned Helvetica (which all Apple devices have by default) to sans-serif, by way of Arial, Frutiger and Nimbus Sans L.

As an Ubuntu user, I see Arial, which is perfectly pleasant. On my Android devices I see the default sans-serif font (Droid Sans I believe), which actually works rather well on mobile — you’d almost think that’s what it was designed for!

What else? Standard stuff. Few or no images and SVG where possible

Beyond this, it’s really just the standard. The homepage of sustywp.com has no images and just one SVG which is loaded inline rather than by an HTTP request. The CSS is minified. Everything gets Gzipped. The server is tuned with NGINX and Fast-CGI cache to serve content from memory.

Bonus SPA-like features without the work or code

When I was boring my girlfriend, Daisy, with my plans, I asked her how she felt conceptually about a website not having a navigation, and it instead being on its own page, found via a „menu” button. She thought it sounded ok. So, when I came to show it to her, I watched eagerly as she clicked the menu link. Her response was that she didn’t really think about clicking to see the menu, and the menu appearing, as changing pages. This confirmed one of my fears that my previous obsession with eliminating page loads when building Single Page Apps (SPAs) is something that only really bothers web developer-y types. Most people don’t really notice it or think about it. So, if you make your website lightning fast, the page loads themselves are almost imperceptible anyway.

With that being the case, I figured why not just pretend it was a menu overlay? So, I added a cross dismiss button and a tiny bit of JavaScript to take you from the menu back to the previous page if you click it. (I did initially implement this in PHP using the $_SERVER superglobal and HTTP_REFERER, but this breaks when using something like FastCGI cache to serve pages (i.e. those pages there is no $_SERVER superglobal.)

There’s still more to come

We all know that things can always be better. Here are a few of the things I’m working on to improve Susty:

  • Finish reading Jeremy Keith’s book Going Offline so I can implement a Service Worker and make Susty even more performant.
  • Look to see how I can implement Gutenberg. It’s going to add a bunch of kilobytes and that makes me sad! 😉
  • Currently, sustywp.com is hosted in one data center in London, and served globally from that location. This means that someone in Wellington, New Zealand is not going to get the full experience! I have a longer-term plan of establishing my own little CDN of edge servers (each one hosted by a 100% renewable energy powered host in each location that I can find one) just running NGINX and serving cached versions of the site. This is a simplified way of how we do things on WordPress.com VIP.

In conclusion

Susty is an example of taking sustainable design techniques to an extreme. I’m not suggesting that we should all start building websites with this exact method. But I do think sustainability should be a much higher priority in the web design industry. It’s good to think about saving any kilobytes we can, and to think in terms of kilobytes rather than megabytes. If you do want to use a JavaScript interface library, why not try out Choo.js, which has React-like features and comes in at just 4KB. Remember, NASA managed to put a man on the moon with about 50KB of data storage at their disposal.

The best thing about all this is that efficient websites means faster websites, which means:

  • Happier users
  • Better search engine placement
  • Happier servers

The post Delivering WordPress in 7KB appeared first on CSS-Tricks.

The Best Alternatives to the 10 Most Popular Fonts

Post pobrano z: The Best Alternatives to the 10 Most Popular Fonts

We see them on a daily basis—these popular fonts are everywhere! Check out this article to find hand-picked alternatives to some popular fonts.

Alternatives to the 10 Most Popular Fonts

If you are into fonts, you’ll know that the most popular can become ubiquitous. 

Thankfully, Envato Elements and Graphic River have some great alternatives. We looked at the characteristics of these popular fonts and found their match. These alternatives are beautifully designed, high-quality fonts with, in some cases, many weights to choose from! 

Try updating your design look with these alternatives for a unique style, and you might just start a new trend! 

1. Fonts Similar to Helvetica

Helvetica has been a widely used typeface ever since its release in the 1960s. Here are some typefaces that share the same characteristics and aren’t as overused.

BW Nista Grotesk

Bw Nista is a clean, modernist sans serif font family that provides a neutral tone of voice. It comes in three different sets, each with subtle features portraying different personalities. This typeface is just as functional as the famous Swiss style, thanks to its strict, rational shapes.

The set includes seven weights with matching obliques. It supports European Latin languages, ligatures, old style and tabular figures.

Nista Grotesk
Bw Nista Grotesk

RNS Sisma

RNS Sisma is a workhorse sans serif typeface comprised of nine weights and some alternates. It is neutral yet bold, perfect for getting a message across. 

RNS Sisma
RNS Sisma

2. Fonts Similar to Futura

Futura is an intense, geometric typeface and one of the most recognisable. It was introduced to promote the modern age to the masses in the 1920s.

Noir Pro

Noir Pro is a sans serif font influenced by the early 20th century geometric typefaces. The set ranges from light to heavy weights. This typeface is suited for any job! 

Noir has a rich arsenal of Open Type features for highly professional use and extended Latin, Cyrillic and Greek language support.

Noir Pro
Noir Pro

Lorin

Lorin is inspired by classic geometric fonts with extra personality. It focuses on aesthetic quality typography. It is suited for any type of application.

The font comes in four weights, with formats compatible for web.

Lorin
Lorin

Electro Sans

Electro Sans is a minimalist typeface with a modern take inspired by geometric forms from the 1920s. It’s perfect for headlines and portfolios.

Web fonts are included in the set.

Electro Sans
Electro Sans

3. Fonts Similar to Gotham

Gotham was inspired by architectural signs popular in the mid-twentieth century throughout New York. It is mostly known from Barack Obama’s 2008 presidential campaign. Below we share some typefaces that have the same characteristics with a new spin. 

Catesque

Catesque is designed with a large x-height, making it highly legible at any size. The typeface is fresh and versatile, perfect for any application. 

The typeface comes in five weights and matching italics.

Catesque
Catesque

Bw Modelica

Modelica is a beautifully designed typeface based on geometric shapes. It is minimal and strong, suited for any purpose.

It’s available in four widths, each containing eight weights with matching oblique italics (that’s 64 styles in total!).

Bw Modelica
Bw Modelica

4. Fonts Similar to Times New Roman

Times New Roman, used by The Times, is one of the most influential typefaces in history. Its large x-height and short ascendants and descendants make it highly legible on body text. 

Zimra Serif

Zimra shares the same features as Times New Roman. It has a large x-height and short ascendants and descendants. If you are looking for a timeless typeface, this is a beautifully designed option.

The set features five weights and includes web format.

Zimra Serif
Zimra Serif

Cammron Serif

Cammron is a modern serif font family. This is a great alternative to Times New Roman because of its legibility. The large x-height makes it look very spacious and light. 

The set features four weights, including a web font kit.

Cammron Serif
Cammron Serif

5. Fonts Similar to Avenir

Avenir is an organic interpretation of the geometric style fonts from the 1920s. This font is on the pricey side, so here are some smartly designed options. 

BERLIN

BERLIN is a minimal typeface designed to perfection. This typeface has won a spot on the Envato Elements list of best fonts of the year in 2017. BERLIN is suited for creating headlines—just add some tracking and you will be in love! 

The set comes with three weights, with all formats including web fonts.

Berlin
BERLIN

Bergen Text

Bergen Text has been carefully crafted to improve readability and legibility at small sizes. The typeface is geometric, but it has a very palpable, adorable personality. 

Bergen Text is a family of six fonts. While being a small font family, it has plenty of OpenType features for highly professional use. It includes Extended Latin, Cyrillic (with a Bulgarian character set) and Greek language support.

Bergen Text
Bergen Text

6. Fonts Similar to Proxima Nova

Proxima Nova is a mix of classic geometric proportions and a contemporary feel. Here we have a few options from Envato Elements. 

SIGNIA Pro

SIGNIA Pro is a modern Sans Serif typeface inspired by European city street lettering styles. On a page, this typeface looks fresh and modern.

SIGNIA Pro features two weights, regular and bold. The set also includes Web Fonts.

SIGNIA Pro
SIGNIA Pro

Morton

Is a unique condensed typeface. It is in a grotesque style that lends impact to your design.

The Morton Type Family is available in nine weights.

Morton
Morton

7. Fonts Similar to Century Gothic

Century Gothic is a sans serif typeface in the geometric style. It has a high x-height and the characters are wide, giving it a signature spacious look.

Silver Thread

Silver Thread is a hairline thin geometric sans serif font. It has Art Deco and 1970s elements to it. It’s perfect for any project that needs a typeface which evokes elegance and sophistication. 

The font contains alternate versions for added variety.

Silver Thread
Silver Thread

Gesture

Gesture Sans is a modern sans serif typeface. Its thick strokes make it highly legible in large formats. 

The pack includes OTF, TTF and Web Fonts.

Gesture
Gesture

Liber v2

This typeface is built on the mathematical purity of geometric circles and squares. While its roots are traditional text fonts, it is redesigned for modern use. This linear sans is highly legible and harmonious, making it suitable for headlines or body text. 

The set features ten weights.

Liber v2
Liber v2

8. Fonts Similar to Impact

Impact is a hard-to-miss font. It was originally designed to, like its name, have an impact. Below we have some options from Envato Elements that share the similar characteristics.

Schmalfette

Schmalfette is a digital revival inspired by the typeface Schmalfette Grotesk from the 1950s. Its tall height, heaviness and condensed characteristics make it a great alternative to Impact. Whenever you need to make a bold statement, Schmalfette will be here to do the job. 

Schmalfette offers support for all Latin based and most Eastern European languages.

Schmalfette
Schmalfette

Bw Stretch

Bw Stretch is great for both display and body text purposes. The compressed style is inspired by wood-block designs. The best part of this typeface is the disruptive titling alternates that expand the width dramatically. It’s perfect for when you need an extra kick in your headlines!

The package includes eight weights from Thin to Heavy, covering all European Latin languages. The set is completed by small/petite caps, fractions, case-sensitive forms, discretionary ligatures, and disruptive titling alternates.

Bw Stretch
Bw Stretch

9. Fonts Similar to Trajan

Trajan is a classic typeface inspired by Roman Square Capitals. It is well known for being used in many movie posters. 

Praetoria

Praetoria is meant to be used at a larger point size. It was inspired by the Roman square capitals used in ancient Rome. Some of the lowercase letters are fictitious variations of their uppercase counterparts. A few others are borrowed from the Russian and Greek alphabets.

Praetoria
Praetoria

Antiqua

Antiqua is inspired by first-century Roman inscriptions. It can be used to set body texts and works well in titles and headlines. Antiqua has 175 characters.

Antiqua
Antiqua

10. Fonts Similar to Didot

Didot is a group of typefaces developed in the 1800s by a famous French printing family of the same name.

It features a strong contrast between thick and thin strokes, resulting in an elegant font. It has been used on Vogue’s cover since the 1950s due to its classic, timeless feel.

Domani

Domani, by Jason Walcott, is a digital revival of an old typeface called Didi. It has some unique design details that set it apart from other Didone style typefaces. It has thinner strokes compared to the classic Didot and heavier terminals.

Walcott has created a professional-quality digital version that is faithful to the original design while expanding the character set to make use of OpenType features.

The set supports Latin-based and most Eastern European languages.

Domani
Domani

Giaza

Giaza is a multilingual Didone style typeface. It features smooth curves and subtle indentations, perfect for fashion applications.

The set contains 650 characters, 190 character swashes, Everted & Inverted Alternates, Discretionary Ligatures, Ornaments, Oldstyle Numeral Alternates, and Standard Alternates.

Giaza
Giaza

Gokú

Gokú is a multilingual typeface, initially designed as a stencil font. A very stylish font with heavy strokes and terminals. 

The set includes an array of ligatures, glyphs, and alternates. Bold lines, subtle curves and improved legibility make it perfect for any application.

Gok
Gokú

Conclusion

Looking for more alternatives to a specific font? Let us know in the comments below!

This list of typefaces aims to show that there are many high-quality alternatives to popular fonts. These are excellent resources for any designer’s toolbox.

For more high-quality fonts, be sure to check out Envato Market and Envato Elements. Let us know your favourite typeface in the comments! 

If you liked this article, you might like these: