Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Responsive Design High Performance
Responsive Design High Performance

Responsive Design High Performance:

eBook
€13.98 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Responsive Design High Performance

Chapter 2. Tweaking Your Website for Performance

Right, you must be tired of reading! Well, you'll be happy to know that, from here on, things get a lot more hands-on. In this chapter, we will look at some basic techniques that are available to improve the loading of your website, such as the correct placement of Document Object Model (DOM) elements, and some more advanced techniques such as preloading your content.

But before we get there, let's start with something simple.

Resource placement on the DOM

When you develop a website, it's easy to forget that the placement of elements in the DOM can make a difference to the time it takes to load the content the user views on the site.

Now that we throw all kinds of wonderful scripts into our websites to create mesmerizing animations and make our site responsive, the placement of resources in our DOM is even more relevant.

Yahoo! released a tool (YSlow) a couple of years ago that measured a website's performance, showing what loads and when. With that information, it gave people recommendations to improve the site's performance. One of these recommendations is to put the <script> tags at the bottom of the page just before the closing </body> tag.

Let's now take a look at the following code snippet and understand it:

<head>
<!-- Styles -->
<link rel="stylesheet" href="css/style.css" type="text/css" />
<!-- Scripts -->
<script src...

Adjusting the sections

Let's now tweak the settings:

  1. Open the layout.js file from the js folder, as shown in the following screenshot:
    Adjusting the sections
  2. You should see the following code:
    Adjusting the sections
  3. Below the comment (denoted by //), adjust the section. On line 5, add the following code to let the sections fit into the viewport:
    $('.full-h').css({
        height: win.height()
    });
  4. Refresh the site in your browser, and you should now see that the sections fit into the document window, as shown in the following screenshot:
    Adjusting the sections

Even though the site loads perfectly well and the sections fit well into the viewport, just as the site loads you see the sections on the page for a brief moment, as shown in the following screenshot:

Adjusting the sections

So what happened here? It's quite simple. The jQuery CDN and layout.js files are placed just before the closing </body> tag. While the DOM is being rendered, the JavaScript is still downloading and executes a brief moment after the DOM has been parsed. This is a very small example of a project...

DNS prefetching

DNS prefetching is a useful technique when your website accesses multiple sites that are on different domains.

Here is a code snippet of a DNS prefetch that is placed in the <head> tags:

<link rel="dns-prefetch" href="http://www.paperjetwednesday.com/">

The purpose of DNS prefetching

DNS prefetching attempts to resolve the domain names before the user follows a link to that domain. If the domain has been resolved, the advantage of this will be that there is effectively no delay due to DNS name resolution.

An excellent example of using DNS prefetching would be for results in a search that link to various other domains. Here are a few types of prefetching:

  • -prefetch: This identifies a resource file, such as an image or a CSS style sheet, to be included in the cache
  • -dns-prefetch: This identifies a DNS query to resolve the background so that requests can occur more quickly
  • -prerender (IE only): This identifies a web page to load in the background, if...

Too many DOM Elements

Another big problem with responsive design is hiding and revealing elements based on the current viewport resolution.

Often, the display: none CSS attribute is used to hide the element. It has the effect that you'd expect—it hides the element from the DOM. Being hidden doesn't mean that it's not being rendered in the background.

Hiding an image, for instance, will still make an HTTP request, adding to the load time of your website. Ways to work around this will be discussed in more detail in the next chapter.

Summary

Right, that was quite a mouthful! We looked at quite a few things in this chapter.

The importance of resource placement on the DOM is often overlooked. It's true that placing scripts at the bottom of the page certainly improves performance, but it's also true that some scripts do need to load before the DOM renders (in the case of our example, to adjust the layout).

Using the technique of preloading content can be greatly helpful in improving the initial load of your site. The example showed a gallery that did not exist in the initial DOM render, but the preloaded images were appended into a gallery wrapper once they had been loaded. The great thing about this is that you can create informative feedback using a plugin such as createjs.

DNS prefetching is a very helpful piece of code that can resolve the DNS name in the background for the site that your page might point to. Search engines can greatly benefit from this.

Showing and hiding elements might seem like a great idea...

Left arrow icon Right arrow icon

Description

This book is ideal for developers who have experience in developing websites or possess minor knowledge of how responsive websites work. No experience of high-level website development or performance tweaking is required.

Who is this book for?

This book is ideal for developers who have experience in developing websites or possess minor knowledge of how responsive websites work. No experience of high-level website development or performance tweaking is required.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 15, 2015
Length: 162 pages
Edition : 1st
Language : English
ISBN-13 : 9781784390839
Languages :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Apr 15, 2015
Length: 162 pages
Edition : 1st
Language : English
ISBN-13 : 9781784390839
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
Responsive Web Design with HTML5 and CSS3, Second Edition
€41.99
Responsive Web Design by Example : Beginner's Guide - Second Edition
€36.99
Responsive Design High Performance
€24.99
Total 103.97 Stars icon

Table of Contents

10 Chapters
1. The Good, the Bad, and the Ugly of Responsive Web Design Chevron down icon Chevron up icon
2. Tweaking Your Website for Performance Chevron down icon Chevron up icon
3. Managing Images Chevron down icon Chevron up icon
4. Learning Content Management Chevron down icon Chevron up icon
5. The Fastest HTTP Request is No HTTP Request Chevron down icon Chevron up icon
6. Testing, Testing, and Testing! Chevron down icon Chevron up icon
7. Speeding Up Development with Design Concepts, Patterns, and Programs Chevron down icon Chevron up icon
8. Using Tools for Performance Chevron down icon Chevron up icon
A. Taking the Next Steps Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
(2 Ratings)
5 star 0%
4 star 50%
3 star 0%
2 star 50%
1 star 0%
M Jun 05, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This book is a great resource for intermediate web designers or developers. It walks you through the development of several very simple responsive website examples, with topics like preloading content covered early in the book.The book does note the experience levels expected, in some places. You should be comfortable with basic PHP and JS, in addition to HTML and CSS. The adaptive images example cites as "self-explanatory" code that you find when you open a PHP file. For beginners this will probably be kind of scary, especially if they've seen a syntax error before.So for beginners, the more advanced coverage might feel like too high of a bar. But for intermediate or advanced-level developers, that is the kind of thing that differentiates this book from the many beginner texts in a valuable way. Even if a lot of the coverage in this book was brief, it gave me an easily-digestible overview that helps me understand 1) when I would use a specific method, 2) why I would use it, and 3) how I would start down that path. Emphasis on the "start" because this is not an in-depth book.The biggest letdown for me, and the reason I'm deducting the first half of a star in this review, is this: When the book started to go into Angular JS and CodeIgniter, I thought it was a pleasant surprise and even got a little excited. The "section" on CodeIgniter even makes this statement: "This section goes by the assumption that you have experience using PHP and have also connected to a database before, as this will not guide you through the steps to do so." Wow, exciting! I'm ready. BUT: This is followed by absolutely no information on CodeIgniter or its role in the Responsive Design process. The book never mentions CodeIgniter again. Huh? Admittedly CodeIgniter and AngularJS content does feel like a lot to expect of a book on responsive design, but if you say you're going to deliver, you should deliver.The other half-star deduction comes from the Retina displays section. The information on Retina displays is extremely brief and not high quality, and while the code snippet listed was one I hadn't seen before, I couldn't immediately think of a way to put it to use. I can't emphasize how important it is for a modern website to support high-DPI graphics, and the techniques are not really that lengthy.Regarding the lack of deep coverage: I felt this was a strength. I am an intuitive learner and really appreciate a good high-level overview. I felt that this was one of the book's biggest strengths.There were also some great third-party resources covered in the book that I hadn't come across yet after building responsive sites for 4 years.If you are getting advanced with HTML and CSS, and want to expand your practical javascript toolset a bit more, this book might be a good way to do that. Some very helpful JS snippets are included, and they are brief enough that you probably won't wear yourself out with coding fatigue.Finally, it wasn't major, but I noticed some confusing English text in the differentiation between LESS and SASS. "Some only need to have Python installed..." huh?Overall: Even considering the negatives, for me there is just too much valuable content in this book to rate it lower than four stars--I know I'll refer to parts of it next time I work on a professional project, and that's easily worth the price to me. But please note that I purchased this book during a big sale on the publisher's website and felt like it was a great deal especially considering the cost.Note: I was contacted by Packt, who noticed I purchased the book and offered a reward in exchange for an unbiased review.
Amazon Verified review Amazon
Racykiwi May 25, 2015
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
This is a very thin book, which combined with Dewald Els’s easy to read, “chatty” style, makes this a book you can finish in a single evening.The question though, is whether you would want to.There is no depth to this book. Dewald rushes past each topic, devoting no more than a paragraph to things such as Angular, SASS, progressive enhancement, etags, compression and minification.If you want to learn about Responsive Design, then you will have to look elsewhere. There is no more than a page or two in total of real information here – mostly involving media queries.In most cases Dewald briefly describes a topic, then provides a link and tells you to go and read about it elsewhere.There is a very simple code example in chapter two, just two divs and two css classes, but the two don't match up! It's not hard to figure out what he ment to say, but you do start to wonder about the quality of his work.In chapter 3, he suggests embedding html within strings in the javascript code, as a way of ensuring that the dom elements are only loaded if the screen width is wide enough. I would suggest that this is not best practice as it's a maintenance nightmare!Chapter seven starts with the words: “You’re still here!”. Is the author expecting that any normal reader would have given up by now?I expect that most readers would find the detailed description of how to create sprites (one of the few topics that is described in detail) to be tedious, and not anything that an average web developer wouldn’t already know.This is not the Responsive Design book you are looking for.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.