Chapter 4. Understanding Performance

Key Ideas

A few ideas come up again and again in JCH Optimize's settings. Understanding them makes the rest of the book much easier.

Above and Below the Fold

The fold is the bottom edge of the screen when a page first opens. Content above the fold is visible straight away; content below the fold is only seen after scrolling. The term comes from newspapers, where the most important stories go on the top half of the folded front page.

Many optimizations treat the two parts differently: what is above the fold must load as early as possible, and what is below can wait. But JCH Optimize works on your server, where there is no screen to look at. So instead it counts HTML elements from the top of the page, and you tell it how many of them make up the part above the fold, in the Elements above fold settings. the section called “Step 1: Pre-configuration” shows you how to find the right number.

Figure 4.2. The fold marker shows where your setting places the fold
A web page with a horizontal line drawn just below the bottom of the screen, marking where the configured number of elements ends.

Render-blocking Files

When a browser meets a CSS file, or most JavaScript files, near the top of a page, it stops drawing the page until it has downloaded and processed that file. Such files are render-blocking. A page with many of them stays blank for a long time, even on a fast connection.

JCH Optimize removes render-blocking in two ways: JavaScript is moved to the end of the page and deferred, so it runs after the page is shown; and the small part of your CSS needed for the top of the page is placed directly in the page, while the rest loads in the background.

Critical CSS

Your site's CSS describes how every part of every page looks, but to display the top of one page the browser needs only a small fraction of it. That fraction is the critical CSS. Optimize CSS Delivery finds it, using your Elements above fold setting, and puts it directly in the page so the top of the page can be drawn at once.

Some elements appear at the top of the page only after the page has loaded, for example a cookie notice or a menu built by JavaScript. JCH Optimize can't see them on the server, so you list them as CSS dynamic selectors.

Execution Order and Exclusions

JavaScript files often depend on one another: a slideshow script may need a library to have run first. They must run in the order they appear on the page. CSS files depend on order too, because later rules override earlier ones.

When you tell JCH Optimize to leave a file alone (to exclude it), the remaining files are optimized around it so that everything still runs in the original order. This is called preserving execution order and is the default. For JavaScript you can choose to ignore execution order for a file that doesn't depend on anything, which gives a slightly better result.

Lazy Loading

Lazy loading means not loading something until it is about to be seen. An image halfway down a long page is loaded only when the visitor scrolls towards it. This saves the visitor's data and leaves the connection free for what is visible first. JCH Optimize can lazy load images, iframes (such as embedded maps and videos), audio, video, background images and even whole sections of a page.

Caution

Never lazy load the main image at the top of the page: it would arrive later, not sooner. JCH Optimize only lazy loads below the fold by default, which is why setting the fold correctly matters.

Layers of Caching

A cache is a stored copy of something that is slow to make. Several caches can sit between your site and your visitor, and knowing which ones you have explains why a change sometimes doesn't show up immediately:

JCH Optimize's file cache

The optimized CSS and JavaScript files. Rebuilt automatically when your settings or the source files change. Clear it from the Clean Cache utility.

The page cache

A finished copy of each page. Cleared together with the file cache.

Your host's server cache or a CDN

Copies kept by your hosting company or a content delivery network such as Cloudflare. Clear them from their own control panel, or let JCH Optimize purge Cloudflare for you.

The browser cache

Files your own browser kept from earlier visits. A private window starts with an empty browser cache.

Tip

When a change doesn't seem to have worked, clear the caches from the top of this list down, then check again in a new private window.