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
NZ$26.99 NZ$38.99
Paperback
NZ$48.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

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 : 9781784398552
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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 NZ$7 each
Feature tick icon Exclusive print discounts
$279.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 NZ$7 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total NZ$ 201.97
Responsive Web Design with HTML5 and CSS3, Second Edition
NZ$80.99
Responsive Web Design by Example : Beginner's Guide - Second Edition
NZ$71.99
Responsive Design High Performance
NZ$48.99
Total NZ$ 201.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

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.