How I Used Brotli to Get Even Smaller CSS and JavaScript Files at CDN Scale

Post pobrano z: How I Used Brotli to Get Even Smaller CSS and JavaScript Files at CDN Scale

The HBO sitcom Silicon Valley hilariously followed Pied Piper, a team of developers with startup dreams to create a compression algorithm so powerful that high-quality streaming and file storage concerns would become a thing of the past.

In the show, Google is portrayed by the fictional company Hooli, which is after Pied Piper’s intellectual property. The funny thing is that, while being far from a startup, Google does indeed have a powerful compression engine in real life called Brotli

This article is about my experience using Brotli at production scale. Despite being really expensive and a truly unfeasible method for on-the-fly compression, Brotli is actually very economical and saves cost on many fronts, especially when compared with gzip or lower compression levels of Brotli (which we’ll get into).

Brotli’s beginning…

In 2015, Google published a blog post announcing Brotli and released its source code on GitHub. The pair of developers who created Brotli also created Google’s Zopfli compression two years earlier. But where Zopfli leveraged existing compression techniques, Brotli was written from the ground-up and squarely focused on text compression to benefit static web assets, like HTML, CSS, JavaScript and even web fonts.

At that time, I was working as a freelance website performance consultant. I was really excited for the 20-26% improvement Brotli promised over Zopfli. Zopfli in itself is a dense implementation of the deflate compressor compared with zlib’s standard implementation, so the claim of up to 26% was quite impressive. And what’s zlib? It’s essentially the same as gzip.

So what we’re looking at is the next generation of Zopfli, which is an offshoot of zlib, which is essentially gzip.

A story of disappointment

It took a few months for major CDN players to support Brotli, but meanwhile it was seeing widespread adoption in tools, services, browsers and servers. However, the 26% dense compression that Brotli promised was never reflected in production. Some CDNs set a lower compression level internally while others supported Brotli at origin so that they only support it if it was enabled manually at the origin.

Server support for Brotli was pretty good, but to achieve high compression levels, it required rolling your own pre-compression code or using a server module to do it for you — which is not always an option, especially in the case of shared hosting services.

This was really disappointing for me. I wanted to compress every last possible byte for my clients’ websites in a drive to make them faster, but using pre-compression and allowing clients to update files on demand simultaneously was not always easy.

Taking matters into my own hands

I started building my own performance optimization service for my clients.

I had several tricks that could significantly speed up websites. The service categorized all the optimizations in three groups consisting of several “Content,” “Delivery,” and “Cache” optimizations. I had Brotli in mind for the content optimization part of the service for compressible resources.

Like other compression formats, Brotli comes in different levels of power. Brotli’s max level is exactly like the max volume of the guitar amps in This is Spinal Tap: it goes to 11.

Brotli:11, or Brotli compression level 11, can offer significant reduction in the size of compressible files, but has a substantial trade-off: it is painfully slow and not feasible for on demand compression the same way gzip is capable of doing it. It costs significantly more in terms of CPU time.

In my benchmarks, Brotli:11 takes several hundred milliseconds to compress a single minified jQuery file. So, the only way to offer Brotli:11 to my clients was to use it for pre-compression, leaving me to figure out a way to cache files at the server level. Luckily we already had that in place. The only problem was the fear that Brotli could kill all our processing resources.

Maybe that’s why Pied Piper had to continue rigging its servers for more power.

I put my fears aside and built Brotli:11 as a configurable server option. This way, clients could decide whether enabling it was worth the computing cost.

It’s slow, but gradually pays off

Among several other optimizations, the service for my clients also offers geographic content delivery; in other words, it has a built-in CDN.

Of the several tricks I tried when taking matters into my own hands, one was to combine public CDN (or open-source CDN) and private CDN on a single host so that websites can enjoy the benefits of shared browser cache of public resources without incurring separate DNS lookup and connection cost for that public host. I wanted to avoid this extra connection cost because it has significant impact for mobile users. Also, combining more and more resources on a single host can help get the most of HTTP/2 features, like multiplexing.

I enabled the public CDN and turned on Brotli:11 pre-compression for all compressible resources, including CSS, JavaScript, SVG, and TTF, among other types of files. The overhead of compression did indeed increase on first request of each resource — but after that, everything seemed to run smoothly. Brotli has over 90% browser support and pretty much all the requests hitting my service now use Brotli.

I was happy. Clients were happy. But I didn’t have numbers. I started analyzing the impact of enabling this high density compression on public resources. For this, I recorded file transfer sizes of several popular libraries — including jQuery, Bootstrap, React, and other frameworks — that used common compression methods implemented by other CDNs and found that Brotli:11 compression was saving around 21% compared to other compression formats.

It’s important to note that some of the other public CDNs I compared were already using Brotli, but at lower compression levels. So, the 21% extra compression was really satisfying for me. This number is based on a very small subset of libraries but is not incorrect by a big margin as I was seeing this much gain on all of the websites that I tested.

Here is a graphical representation of the savings.

Vertical bar chart. Compares jQuery, Bootstrap, D3.js, Ant Design, Senamtic UI, Font Awesome, React, Three.js, Bulma and Vue before and after Brotli compression. Brotli compression is always smaller.

You can see the raw data below..Note that the savings for CSS is much more prominent than what JavaScript gets.

Library Original Avg. of Common Compression (A) Brotli:11 (B) (A) / (B) – 1
Ant Design 1,938.99 KB 438.24 KB 362.82 KB 20.79%
Bootstrap 152.11 KB 24.20 KB 17.30 KB 39.88%
Bulma 186.13 KB 23.40 KB 19.30 KB 21.24%
D3.js 236.82 KB 74.51 KB 65.75 KB 13.32%
Font Awesome 1,104.04 KB 422.56 KB 331.12 KB 27.62%
jQuery 86.08 KB 30.31 KB 27.65 KB 9.62%
React 105.47 KB 33.33 KB 30.28 KB 10.07%
Semantic UI 613.78 KB 91.93 KB 78.25 KB 17.48%
three.js 562.75 KB 134.01 KB 114.44 KB 17.10%
Vue.js 91.48 KB 33.17 KB 30.58 KB 8.47%

The results are great, which is what I expected. But what about the overall impact of using Brotli:11 at scale? Turns out that using Brotli:11 for all public resources reduces cost all around:

  • The smaller file sizes are expected to result in lower TLS overhead. That said, it is not easily measurable, nor is it significant for my service because modern CPUs are very fast at encryption. Still, I believe there is some tiny and repeated saving on account of encryption for every request as smaller files encrypt faster.
  • It reduces the bandwidth cost. The 21% savings I got across the board is the case in point. And, remember, savings are not a one-time thing. Each request counts as cost, so the 21% savings is repeated time and again, creating a snowball savings for the cost of bandwidth. 
  • We only cache hot files in memory at edge servers. Due to the widespread browser support for Brotli, these hot files are mostly encoded by Brotli and their small size lets us fit more of them in available memory.
  • Visitors, especially those on mobile devices, enjoy reduced data transfer. This results in less battery use and savings on data charges. That’s a huge win that gets passed on to the users of our clients!

This is all so good. The cost we save per request is not significant, but considering we have a near zero cache miss rate for public resources, we can easily amortize the initial high cost of compression in next several hundred requests. After that,  we’re looking at a lifetime benefit of reduced overhead.

It doesn’t end there

With the mix of public and private CDNs that we introduced as part of our performance optimization service, we wanted to make sure that clients could set lower compression levels for resources that frequently change over time (like custom CSS and JavaScript) on the private CDN and automatically switch to the public CDN for open-source resources that change less often and have pre-configured Brotli:11. This way, our clients can still get a high compression ratio on resources that change less often while still enjoying good compression ratios with instant purge and updates for compressible resources.

This all is done smoothly and seamlessly using our integration tools. The added benefit of this approach for clients is that the bandwidth on the public CDN is totally free with unprecedented performance levels.

Try it yourself!

Testing on a common website, using aggressive compression can easily shave around 50 KB off the page load. If you want to play with the free public CDN and enjoy smaller CSS and JavaScript, you are welcome to use our PageCDN service. Here are some of the most used libraries for your use:

<!-- jQuery 3.5.0 -->
<script src="https://pagecdn.io/lib/jquery/3.5.0/jquery.min.js" crossorigin="anonymous" integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" ></script>


<!-- FontAwesome 5.13.0 -->
<link href="https://pagecdn.io/lib/font-awesome/5.13.0/css/all.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-h20CPZ0QyXlBuAw7A+KluUYx/3pK+c7lYEpqLTlxjYQ=" >


<!-- Ionicons 4.6.3 -->
<link href="https://pagecdn.io/lib/ionicons/4.6.3/css/ionicons.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-UUDuVsOnvDZHzqNIznkKeDGtWZ/Bw9ZlW+26xqKLV7c=" >


<!-- Bootstrap 4.4.1 -->
<link href="https://pagecdn.io/lib/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-L/W5Wfqfa0sdBNIKN9cG6QA5F2qx4qICmU2VgLruv9Y=" >


<!-- React 16.13.1 -->
<script src="https://pagecdn.io/lib/react/16.13.1/umd/react.production.min.js" crossorigin="anonymous" integrity="sha256-yUhvEmYVhZ/GGshIQKArLvySDSh6cdmdcIx0spR3UP4=" ></script>


<!-- Vue 2.6.11 -->
<script src="https://pagecdn.io/lib/vue/2.6.11/vue.min.js" crossorigin="anonymous" integrity="sha256-ngFW3UnAN0Tnm76mDuu7uUtYEcG3G5H1+zioJw3t+68=" ></script>

Our PHP library automatic switches between private and public CDN if you need it to. The same feature is implemented seamlessly in our WordPress plugin that automatically loads public resources over Public CDN. Both of these tools allow full access to the free public CDN. Libraries for JavaScript, Python. and Ruby are not yet available. If you contribute any such library to our Public CDN, I will be happy to list it in our docs.

Additionally, you can use our search tool to immediately find a corresponding resource on the public CDN by supplying a URL of a resource on your website. If none of these tools work for you, then you can check the relevant library page and pick the URLs you want.

Looking toward the future

We started by hosting only the most popular libraries in order to prevent malware spread. However, things are changing rapidly and we add new libraries as our users suggest them to us. You are welcome to suggest your favorite ones, too. If you still want to link to a public or private Github repo that is not yet available on our public CDN, you can use our private CDN to connect to a repo and import all new releases as they appear on GitHub and then apply your own aggressive optimizations before delivery.

What do you think?

Everything we covered here is solely based on my personal experience working with Brotli compression at CDN scale. It just happens to be an introduction to my public CDN as well. We are still a small service and our client websites are only in the hundreds. Still, at this scale the aggressive compression seems to pay off.

I achieved high quality results for my clients and now you can use this free service for your websites as well. And, if you like it, please leave feedback at my email and recommend it to others.

The post How I Used Brotli to Get Even Smaller CSS and JavaScript Files at CDN Scale appeared first on CSS-Tricks.

How I Used Brotli to Get Even Smaller CSS and JavaScript Files at CDN Scale

Post pobrano z: How I Used Brotli to Get Even Smaller CSS and JavaScript Files at CDN Scale

The HBO sitcom Silicon Valley hilariously followed Pied Piper, a team of developers with startup dreams to create a compression algorithm so powerful that high-quality streaming and file storage concerns would become a thing of the past.

In the show, Google is portrayed by the fictional company Hooli, which is after Pied Piper’s intellectual property. The funny thing is that, while being far from a startup, Google does indeed have a powerful compression engine in real life called Brotli

This article is about my experience using Brotli at production scale. Despite being really expensive and a truly unfeasible method for on-the-fly compression, Brotli is actually very economical and saves cost on many fronts, especially when compared with gzip or lower compression levels of Brotli (which we’ll get into).

Brotli’s beginning…

In 2015, Google published a blog post announcing Brotli and released its source code on GitHub. The pair of developers who created Brotli also created Google’s Zopfli compression two years earlier. But where Zopfli leveraged existing compression techniques, Brotli was written from the ground-up and squarely focused on text compression to benefit static web assets, like HTML, CSS, JavaScript and even web fonts.

At that time, I was working as a freelance website performance consultant. I was really excited for the 20-26% improvement Brotli promised over Zopfli. Zopfli in itself is a dense implementation of the deflate compressor compared with zlib’s standard implementation, so the claim of up to 26% was quite impressive. And what’s zlib? It’s essentially the same as gzip.

So what we’re looking at is the next generation of Zopfli, which is an offshoot of zlib, which is essentially gzip.

A story of disappointment

It took a few months for major CDN players to support Brotli, but meanwhile it was seeing widespread adoption in tools, services, browsers and servers. However, the 26% dense compression that Brotli promised was never reflected in production. Some CDNs set a lower compression level internally while others supported Brotli at origin so that they only support it if it was enabled manually at the origin.

Server support for Brotli was pretty good, but to achieve high compression levels, it required rolling your own pre-compression code or using a server module to do it for you — which is not always an option, especially in the case of shared hosting services.

This was really disappointing for me. I wanted to compress every last possible byte for my clients’ websites in a drive to make them faster, but using pre-compression and allowing clients to update files on demand simultaneously was not always easy.

Taking matters into my own hands

I started building my own performance optimization service for my clients.

I had several tricks that could significantly speed up websites. The service categorized all the optimizations in three groups consisting of several “Content,” “Delivery,” and “Cache” optimizations. I had Brotli in mind for the content optimization part of the service for compressible resources.

Like other compression formats, Brotli comes in different levels of power. Brotli’s max level is exactly like the max volume of the guitar amps in This is Spinal Tap: it goes to 11.

Brotli:11, or Brotli compression level 11, can offer significant reduction in the size of compressible files, but has a substantial trade-off: it is painfully slow and not feasible for on demand compression the same way gzip is capable of doing it. It costs significantly more in terms of CPU time.

In my benchmarks, Brotli:11 takes several hundred milliseconds to compress a single minified jQuery file. So, the only way to offer Brotli:11 to my clients was to use it for pre-compression, leaving me to figure out a way to cache files at the server level. Luckily we already had that in place. The only problem was the fear that Brotli could kill all our processing resources.

Maybe that’s why Pied Piper had to continue rigging its servers for more power.

I put my fears aside and built Brotli:11 as a configurable server option. This way, clients could decide whether enabling it was worth the computing cost.

It’s slow, but gradually pays off

Among several other optimizations, the service for my clients also offers geographic content delivery; in other words, it has a built-in CDN.

Of the several tricks I tried when taking matters into my own hands, one was to combine public CDN (or open-source CDN) and private CDN on a single host so that websites can enjoy the benefits of shared browser cache of public resources without incurring separate DNS lookup and connection cost for that public host. I wanted to avoid this extra connection cost because it has significant impact for mobile users. Also, combining more and more resources on a single host can help get the most of HTTP/2 features, like multiplexing.

I enabled the public CDN and turned on Brotli:11 pre-compression for all compressible resources, including CSS, JavaScript, SVG, and TTF, among other types of files. The overhead of compression did indeed increase on first request of each resource — but after that, everything seemed to run smoothly. Brotli has over 90% browser support and pretty much all the requests hitting my service now use Brotli.

I was happy. Clients were happy. But I didn’t have numbers. I started analyzing the impact of enabling this high density compression on public resources. For this, I recorded file transfer sizes of several popular libraries — including jQuery, Bootstrap, React, and other frameworks — that used common compression methods implemented by other CDNs and found that Brotli:11 compression was saving around 21% compared to other compression formats.

It’s important to note that some of the other public CDNs I compared were already using Brotli, but at lower compression levels. So, the 21% extra compression was really satisfying for me. This number is based on a very small subset of libraries but is not incorrect by a big margin as I was seeing this much gain on all of the websites that I tested.

Here is a graphical representation of the savings.

Vertical bar chart. Compares jQuery, Bootstrap, D3.js, Ant Design, Senamtic UI, Font Awesome, React, Three.js, Bulma and Vue before and after Brotli compression. Brotli compression is always smaller.

You can see the raw data below..Note that the savings for CSS is much more prominent than what JavaScript gets.

Library Original Avg. of Common Compression (A) Brotli:11 (B) (A) / (B) – 1
Ant Design 1,938.99 KB 438.24 KB 362.82 KB 20.79%
Bootstrap 152.11 KB 24.20 KB 17.30 KB 39.88%
Bulma 186.13 KB 23.40 KB 19.30 KB 21.24%
D3.js 236.82 KB 74.51 KB 65.75 KB 13.32%
Font Awesome 1,104.04 KB 422.56 KB 331.12 KB 27.62%
jQuery 86.08 KB 30.31 KB 27.65 KB 9.62%
React 105.47 KB 33.33 KB 30.28 KB 10.07%
Semantic UI 613.78 KB 91.93 KB 78.25 KB 17.48%
three.js 562.75 KB 134.01 KB 114.44 KB 17.10%
Vue.js 91.48 KB 33.17 KB 30.58 KB 8.47%

The results are great, which is what I expected. But what about the overall impact of using Brotli:11 at scale? Turns out that using Brotli:11 for all public resources reduces cost all around:

  • The smaller file sizes are expected to result in lower TLS overhead. That said, it is not easily measurable, nor is it significant for my service because modern CPUs are very fast at encryption. Still, I believe there is some tiny and repeated saving on account of encryption for every request as smaller files encrypt faster.
  • It reduces the bandwidth cost. The 21% savings I got across the board is the case in point. And, remember, savings are not a one-time thing. Each request counts as cost, so the 21% savings is repeated time and again, creating a snowball savings for the cost of bandwidth. 
  • We only cache hot files in memory at edge servers. Due to the widespread browser support for Brotli, these hot files are mostly encoded by Brotli and their small size lets us fit more of them in available memory.
  • Visitors, especially those on mobile devices, enjoy reduced data transfer. This results in less battery use and savings on data charges. That’s a huge win that gets passed on to the users of our clients!

This is all so good. The cost we save per request is not significant, but considering we have a near zero cache miss rate for public resources, we can easily amortize the initial high cost of compression in next several hundred requests. After that,  we’re looking at a lifetime benefit of reduced overhead.

It doesn’t end there

With the mix of public and private CDNs that we introduced as part of our performance optimization service, we wanted to make sure that clients could set lower compression levels for resources that frequently change over time (like custom CSS and JavaScript) on the private CDN and automatically switch to the public CDN for open-source resources that change less often and have pre-configured Brotli:11. This way, our clients can still get a high compression ratio on resources that change less often while still enjoying good compression ratios with instant purge and updates for compressible resources.

This all is done smoothly and seamlessly using our integration tools. The added benefit of this approach for clients is that the bandwidth on the public CDN is totally free with unprecedented performance levels.

Try it yourself!

Testing on a common website, using aggressive compression can easily shave around 50 KB off the page load. If you want to play with the free public CDN and enjoy smaller CSS and JavaScript, you are welcome to use our PageCDN service. Here are some of the most used libraries for your use:

<!-- jQuery 3.5.0 -->
<script src="https://pagecdn.io/lib/jquery/3.5.0/jquery.min.js" crossorigin="anonymous" integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" ></script>


<!-- FontAwesome 5.13.0 -->
<link href="https://pagecdn.io/lib/font-awesome/5.13.0/css/all.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-h20CPZ0QyXlBuAw7A+KluUYx/3pK+c7lYEpqLTlxjYQ=" >


<!-- Ionicons 4.6.3 -->
<link href="https://pagecdn.io/lib/ionicons/4.6.3/css/ionicons.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-UUDuVsOnvDZHzqNIznkKeDGtWZ/Bw9ZlW+26xqKLV7c=" >


<!-- Bootstrap 4.4.1 -->
<link href="https://pagecdn.io/lib/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-L/W5Wfqfa0sdBNIKN9cG6QA5F2qx4qICmU2VgLruv9Y=" >


<!-- React 16.13.1 -->
<script src="https://pagecdn.io/lib/react/16.13.1/umd/react.production.min.js" crossorigin="anonymous" integrity="sha256-yUhvEmYVhZ/GGshIQKArLvySDSh6cdmdcIx0spR3UP4=" ></script>


<!-- Vue 2.6.11 -->
<script src="https://pagecdn.io/lib/vue/2.6.11/vue.min.js" crossorigin="anonymous" integrity="sha256-ngFW3UnAN0Tnm76mDuu7uUtYEcG3G5H1+zioJw3t+68=" ></script>

Our PHP library automatic switches between private and public CDN if you need it to. The same feature is implemented seamlessly in our WordPress plugin that automatically loads public resources over Public CDN. Both of these tools allow full access to the free public CDN. Libraries for JavaScript, Python. and Ruby are not yet available. If you contribute any such library to our Public CDN, I will be happy to list it in our docs.

Additionally, you can use our search tool to immediately find a corresponding resource on the public CDN by supplying a URL of a resource on your website. If none of these tools work for you, then you can check the relevant library page and pick the URLs you want.

Looking toward the future

We started by hosting only the most popular libraries in order to prevent malware spread. However, things are changing rapidly and we add new libraries as our users suggest them to us. You are welcome to suggest your favorite ones, too. If you still want to link to a public or private Github repo that is not yet available on our public CDN, you can use our private CDN to connect to a repo and import all new releases as they appear on GitHub and then apply your own aggressive optimizations before delivery.

What do you think?

Everything we covered here is solely based on my personal experience working with Brotli compression at CDN scale. It just happens to be an introduction to my public CDN as well. We are still a small service and our client websites are only in the hundreds. Still, at this scale the aggressive compression seems to pay off.

I achieved high quality results for my clients and now you can use this free service for your websites as well. And, if you like it, please leave feedback at my email and recommend it to others.

The post How I Used Brotli to Get Even Smaller CSS and JavaScript Files at CDN Scale appeared first on CSS-Tricks.

A/B Testing Instant.Page With Netlify and Speedcurve

Post pobrano z: A/B Testing Instant.Page With Netlify and Speedcurve

Instant.Page does one special thing to make sites faster: it preloads the next page when it’s pretty sure you’re going to click a link (either by hovering over 65ms or mousedown on desktop, or touchstart on mobile), so when you do complete the click (probably a few hundred milliseconds later), it loads that much faster.

It’s one thing to understand that approach, buy into it, integrate it, and consider it a perf win. I have it installed here!

It’s another thing to actually get the data on your own site. Leave it to Tim Kadlec to get clever and A/B test it. Tim was able to do a 50/50 A/B split with performance-neutral Netlify split testing. Half loaded Instant.Page, the other half didn’t. And the same halves told SpeedCurve which half they were in, so performance charts could be built to compare.

Tim says it mostly looks good, but his site probably isn’t the best test:

It’s also worth noting that even if the results do look good, just because it does or doesn’t make an impact on my site doesn’t mean it won’t have a different impact elsewhere. My site has a short session length, typically, and very lightweight pages: putting this on a larger commercial site would inevitably yield much different results.

I’d love to see someone do this on a beefier site. I’m in the how could it not be faster?! camp, but with zero data.

Direct Link to ArticlePermalink

The post A/B Testing Instant.Page With Netlify and Speedcurve appeared first on CSS-Tricks.

How to Create a Tri-Fold Brochure in Affinity Publisher (Free Brochure File)

Post pobrano z: How to Create a Tri-Fold Brochure in Affinity Publisher (Free Brochure File)

Final product image
What You’ll Be Creating

In this tutorial, you’ll learn how to create a tri-fold brochure template in Affinity Publisher. Adaptable for a range of businesses and purposes, this Affinity Publisher brochure template is simple to create and features contemporary colors and typography.

This tri-fold brochure template tutorial comes complete with a downloadable free brochure template for both Adobe InDesign and Affinity Publisher, allowing you to quickly create your own unique tri-fold brochure template. 

brochure template

Follow the steps below to get to grips with Affinity Publisher, pick up key print design skills, and create a stylish Affinity Publisher brochure template from scratch. 

Follow along with this tutorial over on our Envato Tuts+ YouTube channel, where you can find more Affinity tutorials:

What You Will Learn in This Brochure Tutorial

  • How to set up blank brochure templates for print in Affinity Publisher.
  • How to create layers and color swatches and work with images in your Publisher brochure templates.
  • How to use blending modes and format typography on your brochure templates in Affinity Publisher.
  • How to export your tri-fold flyer template as a press-ready PDF, ready for printing.

Looking for more Affinity Publisher templates, InDesign brochure templates, and blank brochure templates? Don’t miss the wide selection of brochure templates on Envato Elements

What You’ll Need to Create Your Tri-Fold Brochure Template

In this tutorial, we’ll be using Affinity Publisher to create our three-fold brochure template. If you’re an InDesign user, you can download the InDesign brochure template here. 

As well as access to Affinity Publisher, you’ll also need to download the following fonts and images from Envato Elements to recreate the tri-fold brochure template pictured here:

I also used these images for the interior design tri-fold brochure template (pictured in the tutorial):

interior tri fold brochure

1. How to Set Up Your Blank Brochure Template in Affinity Publisher

Step 1

Open Publisher, and go to File > New. 

Select Print from the options along the top of the window. Set the Page width to 11 in and Page height to 8.5 in. Increase the Number of pages to 2. 

new document

Step 2

From the Margins options, set a margin width of 0.375 in for all sides of the page. Add a Bleed width of 0.125 in. 

Then click Create

new document

Step 3

To mark out the folds in our brochure template, make sure the rulers are visible (View > Show Rulers). 

Double-click on Master A in the Pages panel (View > Studio > Pages), and pull out a guide from the left-hand ruler to 3.66 in. 

guide for fold

Then pull out a second guide to 7.33 in.

Step 4

To make sure we place content centrally on each section of the tri-fold brochure, we can add margin lines on either side of each fold. 

Pull out guides to 3.29 in, 4.05 in, 6.95 in, and 7.69 in. 

guides for margins

Step 5

Go to the Swatches panel (View > Studio > Swatches) and choose Add Global Colour from the drop-down menu in the top-right corner. 

add global colour

Name the swatch Off-White and set the levels below to C=3 M=1 Y=4 K=0. Then click Add

off white swatch

Repeat to create two more swatches:

  • Navy: C=100 M=89 Y=39 K=32
  • Orange: C=3 M=82 Y=97 K=0
navy swatch
orange swatch

Step 6

Double-click on Page 1 in the Pages panel to go back to the pages of your document.

Go to the Layers panel (View > Studio > Layers) and rename Layer 1 as Background

rename layer 1

Click on the Add Layer button at the bottom right of the panel. Name this second layer Images and Color. Repeat to create a third layer, naming this Text

final new layer

Select both the Text and Images and Color layers and lock them by clicking the padlock icon at top right. 

locked layers

2. How to Add Color and Images to Your Affinity Publisher Brochure Template

Step 1

Working on the Background layer, select the Rectangle Tool (M) from the Tools panel and drag across the whole of Page 1, extending the edges up to the bleed. 

From the Swatches panel, set the Fill Color to Off-White. 

background swatch

Step 2

Use the Rectangle Tool to create a second shape on Page 1, across the central and right-hand section of the trifold brochure. 

Set the Fill to Orange

fill to orange

Step 3

Switch to the Picture Frame Rectangle Tool (F) and create a frame across the bottom half of Page 1, across the left-hand and central section.

picture frame tool

Go to File > Place, choose an image, such as this one, and click Open

Double-click inside the picture frame to select the image directly, and scale it until you’re happy with the position. 

image placed

Step 4

Select the picture frame and Edit > Copy, Edit > Paste it, moving the copy up to the top-right corner of the tri-fold brochure template. 

pasted image frame

Use File > Place to replace the image with a different one, such as this one

placed image

Step 5

Use the Rectangle Tool to create a shape across the bottom of the central section, setting the Fill to Navy

fill to navy

From the Colour panel (View > Studio > Colour), reduce the Opacity to 80%. 

opacity of shape

Step 6

Select the navy shape and Copy and Paste it, moving it directly above the original. Switch the Fill to Orange

fill to orange

In the Layers panel, choose Multiply for the Blending Mode.

multiply blending

Step 7

Select the image frame at the top-right of Page 1, and Edit > Copy it.

Scroll down to Page 2 and Edit > Paste, expanding the picture frame to fill the whole page of the tri-fold brochure template and scaling the image inside to fit it. 

image frame

Step 8

Select the navy rectangle on Page 1 and Copy it, pasting it onto Page 2.

pasted navy shape

Select the orange shape on the central section of Page 1 and Copy that too, pasting onto Page 2. Resize it so it fits across the whole of the left-hand section of the tri-fold brochure. 

pasted orange shape

Paste again, moving the orange shape over to the right-hand section and scaling it to fill the lower two thirds of the section. 

pasted orange shape

3. How to Format Stylish Typography for Your Affinity Publisher Brochure Template

Step 1

Lock the Text and Color layer and unlock the top layer, Text

Select the Frame Text Tool (T) and drag across the bottom of the far-right section of Page 1, using the margin guides to position the frame. 

Type in the brochure title, and from the Character and Paragraph panels (View > Studio > Character), set the Font to Mondia, Size 52 pt, and Align Center. 

Set the Font Colour to Off-White. 

brochure title

Add a subtitle below the heading, set in CA Saygon Text, Size 10 pt.

sub-heading text

Step 2

Over the blue shape, create another text frame for a sub-heading, setting the Font to Mondia, Size 20 pt, and Align Left. 

sub-heading text frame

From the Typography panel, check the All Caps icon. 

Create a larger text frame below this for body text, setting the Font to CA Saygon Text, Size 10 pt. 

body text frame

Add a pull-quote above, set in Mondia, Size 19 pt, Align Right. 

pull quote

Step 3

The white space at the top of the left-hand section is a good place for contact details. 

Set subtitles in Mondia, 20 pt, and a Navy Font Color.

find us text

Body text should be CA Saygon Text, 10 pt.

contact us text

Step 4

Select the sub-heading and body text frame on the central section of Page 1, and Copy them. 

Scroll down to Page 2 and Paste

Paste again, moving this over to the top of the left-hand section. 

body text pasted

You can also add more pull quotes or reviews at the top of the right-hand section on Page 2.

pull quote text

Step 5

If you want to add a logo to the front cover of your tri-fold brochure template, unlock the Images and Color layer, and extend the right edge of the orange shape at the top of Page 1, hitting about halfway across the right-hand section. 

orange rectangle

You can either File > Place a logo or create an icon using the shape tools in Publisher, such as the Ellipse Tool (M).

elllipse tool

4. How to Export Your Tri-Fold Brochure Template for Print

Step 1

When you’ve finished working on your Affinity Publisher brochure template, it’s time to export your artwork as a PDF, ready for sending to print. 

Make sure to File > Save your work, before going to File > Export. 

In the window that opens, choose PDF from the icon options at the top, and select PDF (press ready) from the Preset menu. 

press ready PDF

Make sure the Raster DPI is set to 300, and that the Include Bleed box is checked.

Then click Export

bleed and raster

Step 2

Name your file, select a folder to save it into, and then hit Save

You can send the exported PDF straight off to the printers—awesome work!

save brochure

Conclusion: Your Finished Tri-Fold Brochure Template

Your Affinity Publisher brochure template is finished—great job! 

final brochure

In this Affinity Publisher tutorial, you’ve picked up a wide range of skills and techniques for creating Affinity Publisher templates, from setting up blank brochure templates in Affinity Publisher to creating color swatches, placing images, and formatting typography to create a stylish and contemporary Affinity Publisher brochure template. 

If you want to compare your tri-fold brochure design with my own, make sure to download the completed Affinity Publisher tri-fold brochure template. It’s also available as an InDesign brochure template.

It’s quick and easy to customise your Affinity Publisher brochure template further, by swapping in different color swatches, fonts, and images. 

The corporate tri-fold brochure design below uses a few different images and a yellow color palette to create a unique style:

corporate brochure template

Looking for more Affinity Publisher templates, blank brochure templates, tri-fold brochure templates and InDesign brochure templates? Discover a wide selection of InDesign brochure templates, Affinity Publisher brochure templates, and more on Envato Elements

Eager to develop your Affinity Publisher skills further? Don’t miss these tips and tutorials:

How to Create a Tri-Fold Brochure in Affinity Publisher (Free Brochure File)

Post pobrano z: How to Create a Tri-Fold Brochure in Affinity Publisher (Free Brochure File)

Final product image
What You’ll Be Creating

In this tutorial, you’ll learn how to create a tri-fold brochure template in Affinity Publisher. Adaptable for a range of businesses and purposes, this Affinity Publisher brochure template is simple to create and features contemporary colors and typography.

This tri-fold brochure template tutorial comes complete with a downloadable free brochure template for both Adobe InDesign and Affinity Publisher, allowing you to quickly create your own unique tri-fold brochure template. 

brochure template

Follow the steps below to get to grips with Affinity Publisher, pick up key print design skills, and create a stylish Affinity Publisher brochure template from scratch. 

Follow along with this tutorial over on our Envato Tuts+ YouTube channel, where you can find more Affinity tutorials:

What You Will Learn in This Brochure Tutorial

  • How to set up blank brochure templates for print in Affinity Publisher.
  • How to create layers and color swatches and work with images in your Publisher brochure templates.
  • How to use blending modes and format typography on your brochure templates in Affinity Publisher.
  • How to export your tri-fold flyer template as a press-ready PDF, ready for printing.

Looking for more Affinity Publisher templates, InDesign brochure templates, and blank brochure templates? Don’t miss the wide selection of brochure templates on Envato Elements

What You’ll Need to Create Your Tri-Fold Brochure Template

In this tutorial, we’ll be using Affinity Publisher to create our three-fold brochure template. If you’re an InDesign user, you can download the InDesign brochure template here. 

As well as access to Affinity Publisher, you’ll also need to download the following fonts and images from Envato Elements to recreate the tri-fold brochure template pictured here:

I also used these images for the interior design tri-fold brochure template (pictured in the tutorial):

interior tri fold brochure

1. How to Set Up Your Blank Brochure Template in Affinity Publisher

Step 1

Open Publisher, and go to File > New. 

Select Print from the options along the top of the window. Set the Page width to 11 in and Page height to 8.5 in. Increase the Number of pages to 2. 

new document

Step 2

From the Margins options, set a margin width of 0.375 in for all sides of the page. Add a Bleed width of 0.125 in. 

Then click Create

new document

Step 3

To mark out the folds in our brochure template, make sure the rulers are visible (View > Show Rulers). 

Double-click on Master A in the Pages panel (View > Studio > Pages), and pull out a guide from the left-hand ruler to 3.66 in. 

guide for fold

Then pull out a second guide to 7.33 in.

Step 4

To make sure we place content centrally on each section of the tri-fold brochure, we can add margin lines on either side of each fold. 

Pull out guides to 3.29 in, 4.05 in, 6.95 in, and 7.69 in. 

guides for margins

Step 5

Go to the Swatches panel (View > Studio > Swatches) and choose Add Global Colour from the drop-down menu in the top-right corner. 

add global colour

Name the swatch Off-White and set the levels below to C=3 M=1 Y=4 K=0. Then click Add

off white swatch

Repeat to create two more swatches:

  • Navy: C=100 M=89 Y=39 K=32
  • Orange: C=3 M=82 Y=97 K=0
navy swatch
orange swatch

Step 6

Double-click on Page 1 in the Pages panel to go back to the pages of your document.

Go to the Layers panel (View > Studio > Layers) and rename Layer 1 as Background

rename layer 1

Click on the Add Layer button at the bottom right of the panel. Name this second layer Images and Color. Repeat to create a third layer, naming this Text

final new layer

Select both the Text and Images and Color layers and lock them by clicking the padlock icon at top right. 

locked layers

2. How to Add Color and Images to Your Affinity Publisher Brochure Template

Step 1

Working on the Background layer, select the Rectangle Tool (M) from the Tools panel and drag across the whole of Page 1, extending the edges up to the bleed. 

From the Swatches panel, set the Fill Color to Off-White. 

background swatch

Step 2

Use the Rectangle Tool to create a second shape on Page 1, across the central and right-hand section of the trifold brochure. 

Set the Fill to Orange

fill to orange

Step 3

Switch to the Picture Frame Rectangle Tool (F) and create a frame across the bottom half of Page 1, across the left-hand and central section.

picture frame tool

Go to File > Place, choose an image, such as this one, and click Open

Double-click inside the picture frame to select the image directly, and scale it until you’re happy with the position. 

image placed

Step 4

Select the picture frame and Edit > Copy, Edit > Paste it, moving the copy up to the top-right corner of the tri-fold brochure template. 

pasted image frame

Use File > Place to replace the image with a different one, such as this one

placed image

Step 5

Use the Rectangle Tool to create a shape across the bottom of the central section, setting the Fill to Navy

fill to navy

From the Colour panel (View > Studio > Colour), reduce the Opacity to 80%. 

opacity of shape

Step 6

Select the navy shape and Copy and Paste it, moving it directly above the original. Switch the Fill to Orange

fill to orange

In the Layers panel, choose Multiply for the Blending Mode.

multiply blending

Step 7

Select the image frame at the top-right of Page 1, and Edit > Copy it.

Scroll down to Page 2 and Edit > Paste, expanding the picture frame to fill the whole page of the tri-fold brochure template and scaling the image inside to fit it. 

image frame

Step 8

Select the navy rectangle on Page 1 and Copy it, pasting it onto Page 2.

pasted navy shape

Select the orange shape on the central section of Page 1 and Copy that too, pasting onto Page 2. Resize it so it fits across the whole of the left-hand section of the tri-fold brochure. 

pasted orange shape

Paste again, moving the orange shape over to the right-hand section and scaling it to fill the lower two thirds of the section. 

pasted orange shape

3. How to Format Stylish Typography for Your Affinity Publisher Brochure Template

Step 1

Lock the Text and Color layer and unlock the top layer, Text

Select the Frame Text Tool (T) and drag across the bottom of the far-right section of Page 1, using the margin guides to position the frame. 

Type in the brochure title, and from the Character and Paragraph panels (View > Studio > Character), set the Font to Mondia, Size 52 pt, and Align Center. 

Set the Font Colour to Off-White. 

brochure title

Add a subtitle below the heading, set in CA Saygon Text, Size 10 pt.

sub-heading text

Step 2

Over the blue shape, create another text frame for a sub-heading, setting the Font to Mondia, Size 20 pt, and Align Left. 

sub-heading text frame

From the Typography panel, check the All Caps icon. 

Create a larger text frame below this for body text, setting the Font to CA Saygon Text, Size 10 pt. 

body text frame

Add a pull-quote above, set in Mondia, Size 19 pt, Align Right. 

pull quote

Step 3

The white space at the top of the left-hand section is a good place for contact details. 

Set subtitles in Mondia, 20 pt, and a Navy Font Color.

find us text

Body text should be CA Saygon Text, 10 pt.

contact us text

Step 4

Select the sub-heading and body text frame on the central section of Page 1, and Copy them. 

Scroll down to Page 2 and Paste

Paste again, moving this over to the top of the left-hand section. 

body text pasted

You can also add more pull quotes or reviews at the top of the right-hand section on Page 2.

pull quote text

Step 5

If you want to add a logo to the front cover of your tri-fold brochure template, unlock the Images and Color layer, and extend the right edge of the orange shape at the top of Page 1, hitting about halfway across the right-hand section. 

orange rectangle

You can either File > Place a logo or create an icon using the shape tools in Publisher, such as the Ellipse Tool (M).

elllipse tool

4. How to Export Your Tri-Fold Brochure Template for Print

Step 1

When you’ve finished working on your Affinity Publisher brochure template, it’s time to export your artwork as a PDF, ready for sending to print. 

Make sure to File > Save your work, before going to File > Export. 

In the window that opens, choose PDF from the icon options at the top, and select PDF (press ready) from the Preset menu. 

press ready PDF

Make sure the Raster DPI is set to 300, and that the Include Bleed box is checked.

Then click Export

bleed and raster

Step 2

Name your file, select a folder to save it into, and then hit Save

You can send the exported PDF straight off to the printers—awesome work!

save brochure

Conclusion: Your Finished Tri-Fold Brochure Template

Your Affinity Publisher brochure template is finished—great job! 

final brochure

In this Affinity Publisher tutorial, you’ve picked up a wide range of skills and techniques for creating Affinity Publisher templates, from setting up blank brochure templates in Affinity Publisher to creating color swatches, placing images, and formatting typography to create a stylish and contemporary Affinity Publisher brochure template. 

If you want to compare your tri-fold brochure design with my own, make sure to download the completed Affinity Publisher tri-fold brochure template. It’s also available as an InDesign brochure template.

It’s quick and easy to customise your Affinity Publisher brochure template further, by swapping in different color swatches, fonts, and images. 

The corporate tri-fold brochure design below uses a few different images and a yellow color palette to create a unique style:

corporate brochure template

Looking for more Affinity Publisher templates, blank brochure templates, tri-fold brochure templates and InDesign brochure templates? Discover a wide selection of InDesign brochure templates, Affinity Publisher brochure templates, and more on Envato Elements

Eager to develop your Affinity Publisher skills further? Don’t miss these tips and tutorials:

Understand why CSS has no effect with the Inactive CSS rules indicator in Firefox DevTools

Post pobrano z: Understand why CSS has no effect with the Inactive CSS rules indicator in Firefox DevTools

It’s useful when DevTools tells you that a declaration is invalid. For example, colr: red; isn’t valid because colr isn’t a valid property. Likewise color: rd; isn’t valid because rd isn’t a valid value. For the most part, a browser’s DevTools shows the declaration as crossed out with a warning () icon. It would be nice if they went a step further to tell you which thing was wrong (or both) and suggest likely fixes, but hey, I don’t wanna look a gift horse in the mouth.

Firefox is starting to go a step further in telling you when certain declarations aren’t valid, not because of a syntax error, but because they don’t meet other qualifications. For example, I tossed a grid-column-gap: 1rem on a random <p> and I was told this in a little popup:

grid-column-gap has no effect on this element since it’s not a flex container, a grid container, or a multi-column container.

Try adding either display:grid, display:flex, or columns:2. Learn more

Well that’s awful handy.

Elijah Manor has a blog post and video digging into this a bit.

Direct Link to ArticlePermalink

The post Understand why CSS has no effect with the Inactive CSS rules indicator in Firefox DevTools appeared first on CSS-Tricks.