Drupal Productivity Web Development

6 Essential Tips to Improve the Performance of Your Drupal Website

Have you noticed that your Drupal website is slow? Before you seek professional assistance to fix the problem, try some simple methods we have described in this post.

thumbnail

While the number of content management systems (CMS) nowadays is quite impressive, more small, mid-sized, and large companies are choosing Drupal, a powerful, secure, and scalable platform with freely available source code that currently ranks third in the Open Source Usage Distribution category worldwide.

The CMS has a huge number of available modules (44,577 at the moment of writing the post). These help Drupal site owners implement any feature imaginable to suit their business needs. For all its advantages, though, a Drupal website, just like a site based on any other CMS, needs to be fine-tuned in order to show the best performance and speed.

Fast website speed is important for two main reasons:

How website speed can impact an online a business

  1. The search engines, with Google at the head of the pack, hate websites running at a snail’s pace. They value good user experience above all else and accept no compromises. If you fail to please the search engines, your site will get lost among millions of other resources without the ghost of a chance to make it to the top of search results pages.
  2. Few of your visitors will agree to wait for more than a couple of seconds until your page loads. To prove how crucial the speed indicator is, consider the case of an online retail company that experienced an 11-percent drop in sales when its website loading time increased by just 500 milliseconds(!).

Whether you’re selling goods online, have a blog, or want to showcase your company on the Internet, you must optimize your site’s performance to avoid losing the audience or customers. How can you do that? Follow the tips below and you should soon notice an increase in your Drupal site’s speed.

6 TIPS ON A DRUPAL WEBSITE PERFORMANCE OPTIMIZATION

How to optimize your Drupal site

Tip #1: Prepare and Use Your Visuals the Right Way

A website packed with colorful images and photographs is likely to enjoy greater popularity among users than pages with only text and a few low-quality visuals. That said, you should remember the other side of the coin: high-resolution images that are not optimized for the web properly can pull your Drupal website’s speed down to the bottom.

We suggest that you apply the following techniques to solve this problem:

<u+2714> Load an image only when a visitor scrolls up or down to get it into view</u+2714>. This is different from the conventional approach, wherein the entire content is loaded at once. When you load an image “on-demand,” this favorably reflects on your website’s speed.

It’s like an elevator in an apartment building: stationary when no residents need to go up or down, it only arrives after someone presses a call button on one of the floors.

How can you implement this technique? Install one of the many modules that developers have created exactly for this purpose, such as Lazy-load or Image Lazy Loader.

<u+2714> Optimize image file sizes.</u+2714> Images that weigh a ton, as we said earlier, are some of the principal causes of bad website performance. Avoid uploading large images to the CMS and then changing their dimensions in the code. It will only make things worse.

What you can do instead is use any graphics editor to resize all your visuals to make them more lightweight and only then add them to your Drupal site. We recommend keeping an image file size below the 1MB limit. Read this post to learn more about optimizing images for the web.

Another image optimization method you can apply is installing the Image Optimize module. It allows you to optimize an image when it’s saved without losing quality.

One word of caution, though. If you’ve switched to Drupal 8 (which you should do, of course), the Image Optimize module for this version is still under active development, with only a more or less stable alpha version up for grabs.

<u+2714> Embed your images right into your CSS stylesheets. </u+2714>How is it possible? Just encode your visuals using the Base64 format before you add them to CSS. In this case, there will be no need to send a request to a server to retrieve the images. Read this post to learn more about the Base64 encoding technique.

Tip #2: Get Rid of Modules You Don’t Need or Those That Are No Longer Supported

Get rid of modules you don't need

Drupal, just like any other CMS, comes with some core functionality. If you need additional features, you can search the Drupal site for suitable modules.

On the one hand, the large variety of modules Drupal offers is a blessing for any website administrator. On the other hand, however, this can negatively impact website performance if an admin gets carried away and installs too many add-ons “just in case.”

It’s like a shopping spree when people purchase things they don’t really need. You read the description of a cutting-edge module for backing up the database, for instance, and say to yourself, “Wow, this is a good one! I want it,” even though you already have a similar tool in your arsenal. Thus, you end up with an array of modules that cause your site to be as slow as molasses in January.

Why so? This is because every extension, even one that’s inactive at the moment, executes its code and may need to fetch some data from the database. By the way, that’s the reason why simply switching your modules to the disabled state won’t do the trick. You have to wipe out the “offending” modules from your site altogether.

Low speed is not the only downside of having too many modules. A module that has received no updates for 6 months or more is a potential backdoor through which cybercriminals can get inside your system. This is a problem common for all content management systems, as the recent wave of hacker attacks on WordPress and Magento sites has illustrated.

Hence, we recommend taking stock of all your modules and uninstalling:

  • redundant ones
  • those you haven’t used for a long time
  • those that have received no updates for several months (half a year or more)

The number of modules that you install or leave depends on the size of your website and your business requirements. For example, drupal.org recommends running no more than 20 modules on a relatively small website. For more details, visit this page.

One final thing to note is that some modules are so powerful that one can easily replace several. Also, our professional Drupal developers can create one custom module to cover a number of features you need if you have found no suitable ready-cooked solution. The bottom line: the fewer modules you have, the better your site performs.

Tip #3: Display the Content from the Local Memory Storage

Use the Drupal caching mechanism and modules

What we actually mean by the local memory storage is the cache. On a user’s first visit to a page, its content is loaded into the internal memory or cache. The next time the same user requests the page, it’s retrieved from the local memory storage rather than from a remote server. This increases the website speed hugely.

You should use the state-of-the-art Drupal caching mechanism to the maximum. First, there are two core Drupal modules responsible for caching. The internal cache module caters to guest users who haven’t signed in. The internal dynamic page cache (Drupal 8 feature) covers all types of users and works with the dynamic content in automatic mode.

There are other types of caching as well, such block caching, page caching, views caching, and database caching. All they improve the performance of a Drupal website tremendously.

You can also use the Boost module, provided that your website mostly serves users who don’t have to sign in. The module can cache JavaScript, Ajax, HTML, and XML documents, gzip compressing them in addition. Unfortunately, Drupal 8 users cannot take advantage of the Boost module yet as it’s only being ported to this version.

To Drupal 8 and Drupal 7 site owners, we recommend installing another powerful module — Redis. This backend cache system intended for pages with static content is particularly effective for very complex, frequently updated Drupal websites.

When a user visits a website for the first time, Redis caches the database queries. Other visitors who come to the same page are displayed the cached content. The page doesn’t send any more queries to the database. This results in a considerable loading time reduction.

The Redis module can be a bit challenging to configure for optimal performance. So professional assistance is highly advisable. The benefits you get in terms of your Drupal website performance, though, outweigh any expenses you may incur.

Tip #4: Give Your Users Access to Your Website from a Location Closest to Them

Use a Content Delivery Network

The Internet is a network of computers located in all corners of the globe. Even though modern technologies enable data to travel over the wires incredibly fast, distances still matter when it comes to page loading time.

If your server runs from the USA and most of your visitors come from Europe, why send them to your American server to retrieve a web page? You can simply use one or several servers in Europe to deliver the content to your users. This will significantly reduce data transmission time.

A network of interconnected proxy servers used to distribute content to users in locations closest to them is called a Content Delivery Network (CDN). Most hosting companies provide this feature out of the box.

We also recommend installing the CDN module on your Drupal site. Both Drupal 7 and Drupal 8 administrators can do it. The CDN module takes the URL of a file and alters it so that remote users can retrieve this file from the closest server.

The CDN module has other useful features. For instance, it blocks CDNs from sending REST and HTML responses, only allowing files to be downloaded. This is a great advantage from the SEO point of view.

Tip #5: Bundle CSS and JavaScript Files to Reduce the Number of HTTP Requests

Bundle JS and CSS files

It’s impossible to imagine a modern website without dynamic content and various styles applied. The technologies that make this possible are JavaScript and CSS. There can be a huge number of files of those types on one Drupal website.

Each of them has to be retrieved from the server, with one file equaling one http request. Needless to say that this wave of server calls is a crucial factor that impacts the page load speed.

“But there’s no way I can’t use JavaScript and CSS files,” we hear you saying. We’ve got good news: you can continue using those files without restrictions. The only thing you need to do is glue them together into bundles, or aggregate them in other words.

While the Drupal core provides default aggregation opportunities, they have certain limitations. For example, users have to download copies of the same files every time. Plus, previous files are destroyed whenever the site cache is emptied.

We recommend installing the Advanced CSS/JS Aggregation (AdvAgg) module to resolve those issues. These are just a few things that this module allows you to do:

  • Combine CSS files by using media queries and group them better
  • Add JavaScript to any part of a theme, any block or views
  • Render Cache and cache the generated HTML file
  • Turn off aggregation by using a cookie or the query string in a URL

In addition, the AdvAgg module has a number of submodules to address front-end tasks and protect the site from threats.

Tip #6: Keep Your Database Tidy

The database can also be responsible for the slow loading speed of your Drupal website. This is because various bits and pieces of data get accumulated in it over time. Some of those may be nothing more than clutter without any use. Remove them.

Using the optimize tool through phpMyAdmin is one of the most efficient ways to clean up your database.

Conclusions

WRAPPING UP

The tips above are just some of the measures you can take to improve the performance of a Drupal site. However, they have shown their effectiveness and value for Drupal website owners.

If you want to turn your website into a true rocket, why not contact our Drupal professionals? They have wide experience optimizing the performance and security of Drupal sites regardless of their size and number of features. We are also experts in other Drupal-related tasks, from custom module and theme development to maintenance and support.