12 Steps to Lightning Page Speed

12 Steps to Lightning Page Speed

12 Steps to Lightning Page Speed 1920 1466 WallStreetOasis.com

Posted by WallStreetOasis.com

At Wall Street Oasis, we’ve noticed that every time we focus on improving our page speed, Google sends us more organic traffic. In 2018, our company’s website reached over 80 percent of our traffic from organic search. That’s 24.5 million visits. Needless to say, we are very tuned in to how we can continue to improve our user experience and keep Google happy.

We thought this article would be a great way to highlight the specific steps we take to keep our page speed lightning fast and organic traffic healthy. While this article is somewhat technical (page speed is an important and complex subject) we hope it provides website owners and developers with a framework on how to try and improve their page speed.

Quick technical background: Our website is built on top of the Drupal CMS and we are running on a server with a LAMP stack (plus Varnish and memcache). If you are not using MySQL, however, the steps and principles in this article are still relevant for other databases or a reverse proxy.

Ready? Let’s dig in.

5 Steps to speed up the backend

Before we jump into specific steps that can help you speed up your backend, it might help to review what we mean by “backend”. You can think of the backend of everything that goes into storing data, including the database itself and the servers — basically anything that helps make the website function that you don’t visually interact with. For more information on the difference between the backend vs. frontend, you read this article

Step 1: Make sure you have a Reverse Proxy configured

This is an important first step. For Wall Street Oasis (WSO), we use a reverse proxy called Varnish. It is by far the most critical and fastest layer of cache and serves the majority of the anonymous traffic (visitors logged out). Varnish caches the whole page in memory, so returning it to the visitor is lightning fast.

https://en.wikipedia.org/wiki/Reverse_proxy

Step 2: Extend the TTL of that cache

If you have a large database of content (specifically in the 10,000+ URL range) that doesn’t change very frequently, to drive the hit-rate higher on the Varnish caching layer, you can extend the time to live (TTL basically means how long before you flush the object out of the cache).

For WSO, we went all the way up to two weeks (since we were over 300,000 discussions). At any given time, only a few thousand of those forum URLs are active, so it makes sense to heavily cache the other pages. The downside to this is that when you make any sitewide, template or design changes, you have to wait two weeks for it to arrive across all URLs.

Step 3: Warm up the cache

In order to keep our cache “warm,” we have a specific process that hits all the URLs in our sitemap. This increases the likelihood of a page being in the cache when a user or Google bot visits those same pages (i.e. our hit rate improves). It also keeps Varnish full of more objects, ready to be accessed quickly.

As you can see from the chart below, the ratio of “cache hits” (green) to total hits (blue+green) is over 93 percent.

Step 4: Tune your database and focus on the slowest queries

On WSO, we use a MySQL database. Make sure you enable the slow queries report and check it at least every quarter. Check the slowest queries using EXPLAIN. Add indexes where needed and rewrite queries that can be optimized.

On WSO, we use a MySQL database. To tune MySQL, you can use the following scripts: https://github.com/major/MySQLTuner-perl and https://github.com/mattiabasone/tuning-primer

Step 5: HTTP headers

Use HTTP2 server push to send resources to the page before they are requested. Just make sure you test which ones should be pushed, first. JavaScript was a good option for us. You can read more about it here.

Here is an example of server push from our Investment Banking Interview Questions URL:

; rel=preload; as=script,; rel=preload; as=script,; rel=preload; as=script,

Be sure you’re using the correct format. If it is a script: ; rel=preload; as=script,

If it is a CSS file: ; rel=preload; as=style,

7 Steps to speed up the frontend

The following steps are to help speed up your frontend application. The front-end is the part of a website or application that the user directly interacts with. For example, this includes fonts, drop-down menus, buttons, transitions, sliders, forms, etc.

Step 1: Modify the placement of your JavaScript

Modifying the placement of your JavaScript is probably one of the hardest changes because you will need to continually test to make sure it doesn’t break the functionality of your site. 

I’ve noticed that every time I remove JavaScript, I see page speed improve. I suggest removing as much Javascript as you can. You can minify the necessary JavaScript you do need. You can also combine your JavaScript files but use multiple bundles.

Always try to move JavaScript to the bottom of the page or inline. You can also defer or use the async attribute where possible to guarantee you are not rendering blocking. You can read more about moving JavaScript here.

Step 2: Optimize your images

Use WebP for images when possible (Cloudflare, a CDN, does this for you automatically — I’ll touch more on Cloudflare below). It’s an image formatting that uses both Lossy compression and lossless compression.

    Always use images with the correct size. For example, if you have an image that is displayed in a 2” x 2 ” square on your site, don’t use a large 10” x 10” image. If you have an image that is bigger than is needed, you are transferring more data through the network and the browser has to resize the image for you

    Use lazy load to avoid/delay downloading images that are further down the page and not on the visible part of the screen.

    Step 3: Optimize your CSS

    You want to make sure your CSS is inline. Online tools like this one can help you find the critical CSS to be inlined and will solve the render blocking. Bonus: you’ll keep the cache benefit of having separate files.

    Make sure to minify your CSS files (we use AdVagg since we are on the Drupal CMS, but there are many options for this depending on your site).  

    Try using less CSS. For instance, if you have certain CSS classes that are only used on your homepage, don’t include them on other pages. 

    Always combine the CSS files but use multiple bundles. You can read more about this step here.

    Move your media queries to specific files so the browser doesn’t have to load them before rendering the page. For example:

    If you’d like more info on how to optimize your CSS, check out Patrick Sexton’s interesting post.

    Step 4: Lighten your web fonts (they can be HEAVY)

    This is where your developers may get in an argument with your designers if you’re not careful. Everyone wants to look at a beautifully designed website, but if you’re not careful about how you bring this design live, it can cause major unintended speed issues. Here are some tips on how to put your fonts on a diet:

    • Use inline svg for icon fonts (like font awesome). This way you’ll reduce the critical chain path and will avoid empty content when the page is first loaded.
    • Use fontello to generate the font files. This way, you can include only the glyphs you actually use which leads to smaller files and faster page speed.
    • If you are going to use web fonts, check if you need all the glyphs defined in the font file. If you don’t need Japanese or Arabic characters, for example, see if there is a version with only the characters you need.
    • Use Unicode range to select the glyphs you need.
    • Use woff2 when possible as it is already compressed.
    • This article is a great resource on web font optimization.

    Here is the difference we measured when using optimized fonts:

    After reducing our font files from 131kb to 41kb and removing one external resource (useproof), the fully loaded time on our test page dropped all the way from 5.1 to 2.8 seconds. That’s a 44 percent improvement and is sure to make Google smile (see below).

    Here’s the 44 percent improvement.

    Step 5: Move external resources

    When possible, move external resources to your server so you can control expire headers (this will instruct the browsers to cache the resource for longer). For example, we moved our Facebook Pixel to our server and cached it for 14 days. This means you’ll be responsible to check updates from time to time, but it can improve your page speed score.

    For example, on our Private Equity Interview Questions page it is possible to see how the fbevents.js file is being loaded from our server and the cache control http header is set to 14 days (1209600 seconds)

    cache-control: public, max-age=1209600

    Step 6: Use a content delivery network (CDN)

    What’s a CDN? Click here to learn more.

    I recommend using Cloudflare as it makes a lot of tasks much easier and faster than if you were to try and do them on your own server. Here is what we specifically did on Cloudflare’s configuration:

    Speed

    • Auto-minify, check all
    • Under Polish
    • Enable Brotoli
    • Enable Mirage
    • Choose Lossy
    • Check WebP

    Network

    • Enable HTTP/2 – You can read more about this topic here
    • No browsers currently support HTTP/2 over an unencrypted connection. For practical purposes, this means that your website must be served over HTTPS to take advantage of HTTP/2. Cloudflare has a free and easy way to enable HTTPS. Check it out here.

    Crypto

    • Under SSL
      • Choose Flexible
    • Under TLS 1.3
      • Choose Enable+0RTT – More about this topic here.

    Step 7: Use service workers

    Service workers give the site owner and developers some interesting options (like push notifications), but in terms of performance, we’re most excited about how these workers can help us build a smarter caching system.

    To learn how to to get service workers up and running on your site, visit this page.

    With resources (images, CSS, javascript, fonts, etc) being cached by a service worker, returning visitors will often be served much faster than if there was no worker at all.

    Testing, tools, and takeaways

    For each change you make to try and improve speed, you can use the following tools to monitor the impact of the change and make sure you are on the right path:

    We know there is a lot to digest and a lot of resources linked above, but if you are tight on time, you can just start with Step 1 from both the Backend and Front-End sections. These 2 steps alone can make a major difference on their own.

    Good luck and let me know if you have any questions in the comments. I’ll make sure João Guilherme, my Head of Technology, is on to answer any questions for the community at least once a day for the first week this is published.

    Happy Tuning!

      Sign up for The Moz Top 10, a semimonthly mailer updating you on the top ten hottest pieces of SEO news, tips, and rad links uncovered by the Moz team. Think of it as your exclusive digest of stuff you don’t have time to hunt down but want to read!

      * Checkbox GDPR is required

      *

      I agree

      Will you like to book a consultation today?

      We promise you’ll be glad to have us as the only premium website developer you’ve ever had!

      Will you like to book a consultation today?

      We promise you’ll be glad to have us as the only premium website developer you’ve ever had!

      Bear Design - WordPress Development

      Bear Design provides website development and design, creating content uploaded websites and improving web page placements and web traffic. Bear Design websites are unique, easy to use and responsive. Site owners can easily edit the content, or can trust the Bear Design & Communications to keep them up to date and supply quality content regularly.


      GET IN TOUCH
      160 City Road, EC1V 2NX London, United Kingdom
      Monday – Thursday: 9:00 AM – 5:00 PM
      Friday: 9:00 AM – 2:00 PM

      WE ARE IN LONDON

      Bear Design - WordPress Development

      Bear Design provides website development and design, creating content uploaded websites and improving web page placements and web traffic. Bear Design websites are unique, easy to use and responsive. Site owners can easily edit the content, or can trust the Bear Design & Communications to keep them up to date and supply quality content regularly.


      WE ARE IN LONDON

      GET IN TOUCH
      160 City Road, EC1V 2NX London, United Kingdom
      Monday – Thursday: 9:00 AM – 5:00 PM
      Friday: 9:00 AM – 2:00 PM

      Bear Design - WordPress Development

      Bear Design provides website development and design, creating content uploaded websites and improving web page placements and web traffic. Bear Design websites are unique, easy to use and responsive. Site owners can easily edit the content, or can trust the Bear Design & Communications to keep them up to date and supply quality content regularly.


      GET IN TOUCH
      160 City Road, EC1V 2NX London, United Kingdom
      Monday – Thursday: 9:00 AM – 5:00 PM
      Friday: 9:00 AM – 2:00 PM

      WE ARE IN LONDON

      © Made with by Bear Design

      © Made with by Bear Design

        We are Bear Design

        WE DESIGN

        YOUR WORLD

        Bear Design & Communications Ltd.

        Address : 160 City Road, EC1V 2NX London, United Kingdom
        Phone : +36 702 448 100
        Email : [email protected]

        Opening hours :
        Monday – Thursday: 9:00 AM – 5:00 PM
        Friday: 9:00 AM – 2:00 PM

        Are you sure?
        You must approve our cookie policy to use our site. I you refuse it you will redirect to the Google.
        Refuse
        Approve Cookies
        Cookie Policy
        Cookie Policy
        This Bear Design Cookie Policy (“Policy”) outlines the general policy, practices, and types of cookies that Bear Design And Communications Ltd.. (“Bear Design”, “we”, “us” or “our”) may use to improve our services and your experience when visiting our websites.Cookies are small pieces of text used to store information on web browsers. They’re used by many websites to store and receive identifiers and other information on devices, such as a handheld phone or computer. Our site and services use cookies and other similar technologies (collectively in this Policy, “cookies”), in order to provide a better service to you and to generally improve our sites and services. For example, we may use cookies to help direct you to the appropriate part of our websites, by indicating that you are a repeat visitor. We may also use information to present you with services that are matched to your preferences.Some portions of our websites are functional without cookies, and you may generally choose whether to accept cookies. Most web browsers are set to accept cookies by default, however, you may be able to delete cookies yourself through your browser’s cookie manager. To do so, please follow the instructions provided by your web browser. Please note that disabling cookies will reset your session, disable auto-login, and may adversely the availability and functionality of our websites and the services we can provide to you.As part of our services, we may also place cookies on the computers of visitors to websites protected by Bear Design. We do this in order to identify malicious visitors, reduce the chance of blocking legitimate users, and to provide customized services.Our websites use first party cookies (i.e., cookies set directly by Bear Design) as well as third party cookies, as detailed in the table below.
        Type of CookieWhy we use these cookiesWho serves them and where can you find out more information?
        Analytics and research of usersThese are used to understand, improve, and research users visiting //beardesign.me and their needs for our product offerings. For example, we may use cookies to understand what pages a user browses before submitting a sales request form. We do not share information about this analysis with any third parties.Selected third parties listed and defined as follows:
        • Google Analytics – Web traffic tracking – //www.google.com/policies/privacy/
        • Bing – Conversion tracking from Bing ads – https://advertise.bingads.microsoft.com/en-us/resources/policies/microsoft-bing-adsprivacy-policy
        • Doubleclick – Google advertising platform that analyzes browsing activity across website to establish user profile – //www.google.com/policies/technologies/ads/
        • Twitter – Analyzes browsing activity across website to establish user profile – https://support.twitter.com/articles/20170514
        • Facebook – Analyzes browsing activity across website to establish user profile – https://www.facebook.com/policies/cookies/
        A user can delete these cookies through browser settings.
        Improving Website experienceThese provide functionality to help us deliver a better user experience for our website. For example, cookies help facilitate chats with our sales representatives, allow you to search the website, and deliver the user quickly to their intended website location.1st party and selected third parties as defined below:
        • __cfduid 3rd party cookie – This cookie is strictly necessary for Cloudflare’s security features
        • __hssc Cookie for keeping track of sessions. This is used to determine if we should increment the session number and timestamps in the __hstc cookie. It contains: the domain, viewCount (increments each pageView in a session), session start timestamp. (Expires: 30 min)
        • __hssrc Whenever HubSpot changes the session cookie, this cookie is also set. We set it simply to the value “1”, and use it to determine if the user has restarted their browser. If this cookie does not exist when we manage cookies, we assume it is a new session. (Expires: None. Session cookie)
        • __hstc The main cookie for tracking visitors. It contains: the domain, utk (see below), initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session) (Expires: 2 years)
        • hsfirstvisit This cookie used to keep track of a user’s first visit. (Expires: 10 years)
        • hubspotutk This cookie is used for to keep track of a visitor’s identity. This cookie is passed to HubSpot on form submission and used when deduplicating contacts. (Expires: 10 years)
        • wordpress_ WordPress cookie for a logged in user.
        • wordpress_logged_in_ WordPress cookie for a logged in user.
        • wp-settings- WordPress also sets a few wp-settings-[UID] cookies. The number on the end is your individual user ID from the users database table. This is used to customize your view of admin interface, and possibly also the main site interface.
        • wp-settings-time- WordPress also sets a few wp-settings-{time}-[UID] cookies. The number on the end is your individual user ID from the users database table. This is used to customize your view of admin interface, and possibly also the main site interface.
        • __cfduid 3rd party cookie – This cookie is strictly necessary for Cloudflare’s security features
        A user can delete these cookies through browser settings.
        LAST UPDATE: 24.01.2018, LONDON
        Approve
        Refuse
        Cookie Policy
        This Bear Design Cookie Policy (“Policy”) outlines the general policy, practices, and types of cookies that Bear Design And Communications Ltd.. (“Bear Design”, “we”, “us” or “our”) may use to improve our services and your experience when visiting our websites.Cookies are small pieces of text used to store information on web browsers. They’re used by many websites to store and receive identifiers and other information on devices, such as a handheld phone or computer. Our site and services use cookies and other similar technologies (collectively in this Policy, “cookies”), in order to provide a better service to you and to generally improve our sites and services. For example, we may use cookies to help direct you to the appropriate part of our websites, by indicating that you are a repeat visitor. We may also use information to present you with services that are matched to your preferences.Some portions of our websites are functional without cookies, and you may generally choose whether to accept cookies. Most web browsers are set to accept cookies by default, however, you may be able to delete cookies yourself through your browser’s cookie manager. To do so, please follow the instructions provided by your web browser. Please note that disabling cookies will reset your session, disable auto-login, and may adversely the availability and functionality of our websites and the services we can provide to you.As part of our services, we may also place cookies on the computers of visitors to websites protected by Bear Design. We do this in order to identify malicious visitors, reduce the chance of blocking legitimate users, and to provide customized services.Our websites use first party cookies (i.e., cookies set directly by Bear Design) as well as third party cookies, as detailed in the table below.
        Type of CookieWhy we use these cookiesWho serves them and where can you find out more information?
        Analytics and research of usersThese are used to understand, improve, and research users visiting //beardesign.me and their needs for our product offerings. For example, we may use cookies to understand what pages a user browses before submitting a sales request form. We do not share information about this analysis with any third parties.Selected third parties listed and defined as follows:
        • Google Analytics – Web traffic tracking – //www.google.com/policies/privacy/
        • Bing – Conversion tracking from Bing ads – https://advertise.bingads.microsoft.com/en-us/resources/policies/microsoft-bing-adsprivacy-policy
        • Doubleclick – Google advertising platform that analyzes browsing activity across website to establish user profile – //www.google.com/policies/technologies/ads/
        • Twitter – Analyzes browsing activity across website to establish user profile – https://support.twitter.com/articles/20170514
        • Facebook – Analyzes browsing activity across website to establish user profile – https://www.facebook.com/policies/cookies/
        A user can delete these cookies through browser settings.
        Improving Website experienceThese provide functionality to help us deliver a better user experience for our website. For example, cookies help facilitate chats with our sales representatives, allow you to search the website, and deliver the user quickly to their intended website location.1st party and selected third parties as defined below:
        • __cfduid 3rd party cookie – This cookie is strictly necessary for Cloudflare’s security features
        • __hssc Cookie for keeping track of sessions. This is used to determine if we should increment the session number and timestamps in the __hstc cookie. It contains: the domain, viewCount (increments each pageView in a session), session start timestamp. (Expires: 30 min)
        • __hssrc Whenever HubSpot changes the session cookie, this cookie is also set. We set it simply to the value “1”, and use it to determine if the user has restarted their browser. If this cookie does not exist when we manage cookies, we assume it is a new session. (Expires: None. Session cookie)
        • __hstc The main cookie for tracking visitors. It contains: the domain, utk (see below), initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session) (Expires: 2 years)
        • hsfirstvisit This cookie used to keep track of a user’s first visit. (Expires: 10 years)
        • hubspotutk This cookie is used for to keep track of a visitor’s identity. This cookie is passed to HubSpot on form submission and used when deduplicating contacts. (Expires: 10 years)
        • wordpress_ WordPress cookie for a logged in user.
        • wordpress_logged_in_ WordPress cookie for a logged in user.
        • wp-settings- WordPress also sets a few wp-settings-[UID] cookies. The number on the end is your individual user ID from the users database table. This is used to customize your view of admin interface, and possibly also the main site interface.
        • wp-settings-time- WordPress also sets a few wp-settings-{time}-[UID] cookies. The number on the end is your individual user ID from the users database table. This is used to customize your view of admin interface, and possibly also the main site interface.
        • __cfduid 3rd party cookie – This cookie is strictly necessary for Cloudflare’s security features
        A user can delete these cookies through browser settings.
        LAST UPDATE: 24.01.2018, LONDON
        Approve
        Refuse
        Welcome
        We use cookies to ensure that we give you the best experience on our website. Before you continue browsing you must approve or refuse our cookie policy.
        Approve
        Refuse
        Cookie Policy