100% found this document useful (1 vote)
5 views

Instant ebooks textbook (Ebook) Developing Responsive Web Applications with AJAX and jQuery by Sandeep Kumar Patel ISBN 9781783286379, 1783286377 download all chapters

The document provides information about the ebook 'Developing Responsive Web Applications with AJAX and jQuery' by Sandeep Kumar Patel, including download links and ISBN details. It also lists additional recommended ebooks on related topics, such as responsive web design and AJAX programming. The content covers various aspects of responsive web application development, including integration with social media platforms and e-commerce functionalities.

Uploaded by

bamburbavne
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
5 views

Instant ebooks textbook (Ebook) Developing Responsive Web Applications with AJAX and jQuery by Sandeep Kumar Patel ISBN 9781783286379, 1783286377 download all chapters

The document provides information about the ebook 'Developing Responsive Web Applications with AJAX and jQuery' by Sandeep Kumar Patel, including download links and ISBN details. It also lists additional recommended ebooks on related topics, such as responsive web design and AJAX programming. The content covers various aspects of responsive web application development, including integration with social media platforms and e-commerce functionalities.

Uploaded by

bamburbavne
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Visit https://ebooknice.

com to download the full version and


explore more ebooks

(Ebook) Developing Responsive Web Applications with


AJAX and jQuery by Sandeep Kumar Patel ISBN
9781783286379, 1783286377

_____ Click the link below to download _____


https://ebooknice.com/product/developing-responsive-
web-applications-with-ajax-and-jquery-10867566

Explore and download more ebooks at ebooknice.com


Here are some recommended products that might interest you.
You can download now and explore!

(Ebook) Developing Responsive Web Applications with AJAX


and jQuery by Sandeep Kumar Patel ISBN 9781783286379,
9781849699259, 9781782163602, 9781783980369,
9781782162209, 1783286377, 1849699259, 1782163603,
https://ebooknice.com/product/developing-responsive-web-applications-
1783980362
with-ajax-and-jquery-6575944

ebooknice.com

(Ebook) Responsive Web Design with AngularJS by Sandeep


Kumar Patel ISBN 9781784398422, 178439842X

https://ebooknice.com/product/responsive-web-design-with-
angularjs-4985184

ebooknice.com

(Ebook) Responsive Web Design with AngularJS by Sandeep


Kumar Patel ISBN 9781784398422, 178439842X

https://ebooknice.com/product/responsive-web-design-with-
angularjs-47308506

ebooknice.com

(Ebook) Responsive Web Design by Example: Embrace


responsive design with HTML5, CSS3, JavaScript, jQuery and
Bootstrap 4 by Hussain, Frahaan ISBN 9781787287068,
1787287068
https://ebooknice.com/product/responsive-web-design-by-example-
embrace-responsive-design-with-html5-css3-javascript-jquery-and-
bootstrap-4-55872828
ebooknice.com
(Ebook) AJAX And PHP: Building Responsive Web Applications
by Cristian Darie, Bogdan Brinzarea, Filip Chereches-Tosa,
Mihai Bucica ISBN 9781904811824, 1904811825
https://ebooknice.com/product/ajax-and-php-building-responsive-web-
applications-920264

ebooknice.com

(Ebook) Google Web Toolkit: GWT Java AJAX Programming: A


Practical Guide to Google Web Toolkit for Creating AJAX
Applications with Java by Prabhakar Chaganti ISBN
9781847191007, 1847191002
https://ebooknice.com/product/google-web-toolkit-gwt-java-ajax-
programming-a-practical-guide-to-google-web-toolkit-for-creating-ajax-
applications-with-java-974188
ebooknice.com

(Ebook) Flask Web Development: Developing Web Applications


with Python by Miguel Grinberg ISBN 9781449372620,
1449372627
https://ebooknice.com/product/flask-web-development-developing-web-
applications-with-python-4680280

ebooknice.com

(Ebook) Flask Web Development: Developing Web Applications


With Python by Miguel Grinberg ISBN 9781491991732,
1491991739
https://ebooknice.com/product/flask-web-development-developing-web-
applications-with-python-10539006

ebooknice.com

(Ebook) Flask Web Development: Developing Web Applications


With Python by Miguel Grinberg ISBN 9781491991732,
1491991739
https://ebooknice.com/product/flask-web-development-developing-web-
applications-with-python-7316108

ebooknice.com
Developing Responsive Web Applications with AJAX and
jQuery 1st Edition Sandeep Kumar Patel Digital Instant
Download
Author(s): Sandeep Kumar Patel
ISBN(s): 9781783286379, 1783286377
Edition: 1
File Details: PDF, 11.77 MB
Year: 2014
Language: english
www.allitebooks.com
Developing Responsive
Web Applications with
AJAX and jQuery

Design and develop your very own responsive web


applications using Java, jQuery, and AJAX

Sandeep Kumar Patel

BIRMINGHAM - MUMBAI

www.allitebooks.com
Developing Responsive Web Applications with AJAX
and jQuery

Copyright © 2014 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: July 2014

Production reference: 1180714

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78328-637-9

www.packtpub.com

Cover image by Abhishek Pandey (abhishek.pandey1210@gmail.com)

www.allitebooks.com
Credits

Author Project Coordinator


Sandeep Kumar Patel Aaron S. Lazar

Reviewers Proofreaders
Fernando Doglio Simran Bhogal
Md. Zahid Hasan Paul Hindle
Mohammad Amzad Hossain
Indexers
Jake Kronika
Hemangini Bari

Commissioning Editor Rekha Nair


Julian Ursell Priya Subramani

Acquisition Editor Graphics


Mohammad Rizvi Abhinash Sahu

Content Development Editor Production Coordinator


Balaji Naidu Shantanu Zagade

Technical Editors Cover Work


Venu Manthena Shantanu Zagade
Mrunmayee Patil

Copy Editors
Roshni Banerjee
Sarang Chari
Janbal Dharmaraj
Gladson Monteiro
Deepa Nambiar
Karuna Narayanan
Adithi Shetty

www.allitebooks.com
About the Author

Sandeep Kumar Patel is a senior web developer and the founder of


www.tutorialsavvy.com, a widely-read programming blog since 2012. He has
more than 4 years of experience in object-oriented JavaScript and JSON-based web
application development. He is GATE 2005 Information Technology (IT) qualified
and has a Master's degree from VIT University, Vellore. At present, he holds the
position of Web Developer in SAP Labs, India. You can find out more about him
from his LinkedIn profile (http://www.linkedin.com/in/techblogger).
He has received the DZone Most Valuable Blogger (MVB) award for technical
publications related to web technologies. His article can be viewed at
http://www.dzone.com/users/sandeepgiet. He has also received the Java
Code Geek (JCG) badge for a technical article published in JCG. His article can be
viewed at http://www.javacodegeeks.com/author/sandeep-kumar-patel/.

www.allitebooks.com
About the Reviewers

Fernando Doglio has been working as a web developer for the past 10 years.
During that time, he fell in love with the Web and has had the opportunity of
working with most of the leading technologies such as PHP, Ruby on Rails,
MySQL, Node.js, AngularJS, AJAX, REST APIs, and others.

In his spare time, he likes to tinker and learn new things, which is why his
GitHub account keeps getting new repos every month. He's also a big open
source supporter and tries to win the support of new people with the help
of his site: http://www.lookingforpullrequests.com/. He can be contacted
on Twitter at @deleteman123.

When not programming, he can be seen spending time with his family.

Md. Zahid Hasan is a professional web developer. He got his BSc and MSc in
Information and Communication Engineering from University of Rajshahi (RU),
Rajshahi. Now, he is working as a Lecturer in the department of Computer Science
and Engineering at Green University of Bangladesh. He previously worked as a
Software Developer at SEleven IT Limited for 2 years in Bangladesh.

He has a wide range of technical skills, Internet knowledge, and experience across
the spectrum of online development in the service of building and improving online
properties for multiple clients. He enjoys creating site architecture and infrastructure,
backend development using open source tools such as Linux, Apache, MySQL,
and PHP (LAMP), and frontend development with CSS and HTML/XHTML.

www.allitebooks.com
Mohammad Amzad Hossain has 7 years of experience building large-scale
complex websites and web applications. He works as a Branch Manager in Sourcetop
Inc. where he leads an offshore team in Dhaka, Bangladesh. His day-to-day life
requires him to plan, analyze, guide, and provide solutions for complex requirements.
In his free time, he digs into recent trends in web development and follows hundreds
of RSS that help him to keep up in the fast-track world of development. He has a BSc
degree in Computer Science Engineering.

Jake Kronika, a software developer and UI architect with over 20 years of


experience, brings to bear extensive proficiency implementing both server-side and
user interface (UI) solutions including multiple responsive web applications to date.

He began his career early in life using online tools for static content and rapidly
progressed to building dynamic applications incorporating databases and server-side
scripting languages. He has been a Senior User Interface Software Engineer at ADP
Dealer Services in Seattle, WA, USA from 2011. Prior to this, he occupied numerous
senior-level positions in the UI space in Chicago, IL. He has also balanced considerable
freelance work under a sole proprietorship named Gridline Design & Development,
accessible at http://gridlined.com/, online since 1999.

Over the past several years, particularly as the HTML, CSS, and JavaScript portions
of websites have experienced rapid evolution, he has continually sought out and
digested new technological knowledge through reading, personal and client projects,
and other means. Some of his favorite current tools include Node.js and AngularJS,
Less/Sass, and Git VCS.

Prior to this book, he was a technical reviewer for the following Packt
Publishing titles:

• Django JavaScript Integration: AJAX and jQuery, Jonathan Hayward,


in January 2011
• jQuery UI 1.8: The User Interface Library for jQuery, Dan Wellman,
in August 2011
• jQuery Tools UI Library, Alex Libby, in February 2012

www.allitebooks.com
www.PacktPub.com

Support files, eBooks, discount offers, and more


You might want to visit www.PacktPub.com for support files and downloads related to
your book.

Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and
as a print book customer, you are entitled to a discount on the eBook copy. Get in touch
with us at service@packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt books
and eBooks.

TM

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can access, read and search across Packt's entire library of books.

Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print and bookmark content
• On demand and accessible via web browser

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view nine entirely free books. Simply use your login credentials for
immediate access.

www.allitebooks.com
www.allitebooks.com
Table of Contents
Preface 1
Chapter 1: Introduction to a Responsive Web Application 7
Benefits of a responsive design 8
Server- versus client-side detection 9
The technology stack 9
HTML5 10
CSS3 and media queries 10
JavaScript 11
Measuring responsiveness 11
Devices and screens 12
Media types 12
Media queries 14
Role of media queries 15
Responsive frameworks 15
Bootstrap 16
The Foundation framework 16
The Cascade framework 16
The Pure CSS framework 17
The Gumby framework 17
Bootstrap 3 for a responsive design 17
What are we building? 18
Summary 19

www.allitebooks.com
Table of Contents

Chapter 2: Creating a Responsive Layout for a Web Application 21


Required software and tools 21
Setting up a Java-based web project 22
Configuring Bootstrap 3 25
Creating a wireframe for a web application 27
Responsive layouts 28
Creating a layout for large and small devices 29
Developing the layout 29
Bootstrap 3 containers 29
Developing a row 31
Developing the menu section 33
Developing the hero section 35
Developing the list of products section 36
The combined layout 41
Verifying the layout 45
The Opera Mobile emulator 45
Summary 52
Chapter 3: Adding Dynamic Visuals to a Web Application 53
Building a JSON servlet 53
Creating a POJO class 53
Creating a product store 55
Converting from POJO to JSON 58
Creating the servlet 58
Building a jQuery AJAX method 62
jQuery promises 64
The jQuery templating mechanism 66
The combined jQuery code 68
The combined HTML markup 69
Modifying the style of the product 71
Building an image carousel 74
Summary 79
Chapter 4: Twitter Integration 81
Introduction to Twitter4J 81
Configuring Twitter4J in a web application 82
Posting a tweet 83
Creating a Twitter button 83
Setting up a new Twitter application 86
The Twitter Permissions tab 88
The Twitter Details tab 89
The Twitter Settings tab 90
The Twitter API Keys tab 90

[ ii ]
Table of Contents

Developing a Twitter servlet 91


Request token 93
Developing a Twitter callback servlet 96
Access token 96
Combining all the pieces 98
Posting a tweet with an image 102
Product store with an image 103
Markup changes 106
Changes in app.js 107
Twitter servlet changes 108
Changes in the Twitter callback servlet 110
User Twitter timeline 111
Summary 111
Chapter 5: Facebook Integration 113
Introduction to the Facebook SDK for JavaScript 113
Creating a Facebook application 115
Configuring the Facebook SDK 117
The Settings tab 118
The Basic configuration 118
The Advanced configuration 119
The Migrations configuration 120
Configuring a Facebook login 120
Configuring the Facebook Like and Share buttons 122
Configuring Facebook comments 127
The combined code 128
Summary 136
Chapter 6: Google+ Integration 137
Introduction to the Google+ API 137
Configuring Google+ 139
Creating a client ID 139
Including the Google script 141
Log in using Google+ 142
Integrating +1 recommendations 144
Summary 149
Chapter 7: Linking Dynamic Content from External Websites 151
Introduction to the YouTube API 151
Configuring a YouTube API 151
Searching for a YouTube video 154
The part parameter 156
The fields parameter 156
The YouTube button markup 156
[ iii ]
Table of Contents

Asynchronous search in YouTube 158


Rendering the YouTube search results 162
Embedding a YouTube video 165
Summary 169
Chapter 8: Integrating E-Commerce or Shopping Applications
with Your Website 171
Creating a shopping cart 171
Adding a product to the cart 171
Displaying the minimal view of the cart 173
Displaying the cart details in a table 174
Configuring the PayPal Developer API 178
Integrating the PayPal Developer API 180
Configuring the Shopify API 191
Integrating the Shopify API 192
Summary 194
Chapter 9: Integrating the Google Currency Converter with
Your Web Application 195
The Google Currency Converter API 195
Configuring the Google Currency Converter API 198
Integrating the Currency Converter API 198
Developing our currency converter 199
Building the currency list dropdown 199
Processing the conversion request 203
Exceptions 208
Summary 208
Chapter 10: Debugging and Testing 209
Implementing the debugging mechanism 210
Dimensions Toolkit 210
The Designmodo Responsive Test tool 210
The Opera Mobile emulator tool 211
The Responsinator tool 211
The Viewport Resizer tool 212
The L-Square Responsive Design Inspector tool 212
The FireBreak add-on 212
The More Display Resolutions 1.0 add-on 213
The BrowserStack Responsive tool 214

[ iv ]
Table of Contents

The MobileTest tool 214


The TestSize tool 215
The Am I Responsive tool 215
The Responsive Design Checker tool 216
The RUIT tool 216
The Responsive Test online tool 217
Testing the app as a whole 217
Summary 219
Index 221

[v]
Preface
Welcome to Developing Responsive Web Applications with AJAX and jQuery. If you
want to learn and understand responsive layout development or social application
integration using AJAX and jQuery, then this book is for you. It covers a systematic
approach for building a responsive web application.

All the key features of a responsive application are explained with the detailed
code. It also explains how to debug and test a responsive web application
during development.

What this book covers


Chapter 1, Introduction to a Responsive Web Application, introduces you to the
responsiveness of an application and lists the key benefits of a responsive
application for a commercial site.

Chapter 2, Creating a Responsive Layout for a Web Application, explains how to develop
a layout that will support different screen sizes to render using Bootstrap 3.

Chapter 3, Adding Dynamic Visuals to a Web Application, explains how to make


a jQuery AJAX call for JSON data and render content in different parts of the
web application.

Chapter 4, Twitter Integration, demonstrates how to integrate the Twitter4J library to


incorporate different features such as tweets and posts from the web application.

Chapter 5, Facebook Integration, demonstrates how to integrate the Facebook SDK to


add the Facebook login and Like features in the web application.

Chapter 6, Google+ Integration, shows how to integrate the Google+ login and +1
feature into the web application.
Preface

Chapter 7, Linking Dynamic Content from External Websites, explains how to integrate
the YouTube API to embed a recommended video into a web application.

Chapter 8, Integrating E-Commerce or Shopping Applications with Your Website, illustrates


the integration of the PayPal payment API into the application. Also, it introduces
the integration of the Shopify API into the application.

Chapter 9, Integrating the Google Currency Converter with Your Web Application,
explains how to integrate the Google Currency API to help a user see the amount
in a different currency.

Chapter 10, Debugging and Testing, introduces the different available online and offline
tools to test a responsive application during development.

What you need for this book


The following list of tools and libraries are required for this book:

• Eclipse IDE for Java EE Developers


• Apache Tomcat 7.0
• Bootstrap 3.0
• jQuery 2.1.0

Who this book is for


This book is for Java web developers who want to create responsive web
applications. This book is also helpful for those who want to learn about the
integration of social applications into existing web applications. Finally, the book
is for everyone interested in better understanding AJAX-based responsive web
application development.

Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.

[2]
Preface

Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"The data-toggle attribute has the value for the effect property such as collapse."

A block of code is set as follows:


<div class="navbar-collapse collapse" id="ts-top-menu">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Category 1</a></li>
<li><a href="#">Category 2</a></li>
<li><a href="#">Category 3</a></li>
</ul>
</div>

When we wish to draw your attention to a particular part of a code block,


the relevant lines or items are set in bold:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="asset/css/bootstrap.min.css">
<title>Responsive product Store</title>
</head>
<body>
<div class="container-fluid"></div>
</body>
</html>

New terms and important words are shown in bold. Words that you see on
the screen, in menus or dialog boxes for example, appear in the text like this:
"The Arguments option is for passing additional arguments."

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

[3]
Preface

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or may have disliked. Reader feedback is important for
us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to feedback@packtpub.com,


and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.

Downloading the example code


You can download the example code files for all Packt books you have purchased
from your account at http://www.packtpub.com. If you purchased this book
elsewhere, you can visit http://www.packtpub.com/support and register to
have the files e-mailed directly to you.

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you would report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the errata submission form link,
and entering the details of your errata. Once your errata are verified, your submission
will be accepted and the errata will be uploaded on our website, or added to any list of
existing errata, under the Errata section of that title. Any existing errata can be viewed
by selecting your title from http://www.packtpub.com/support.

[4]
Preface

Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media.
At Packt, we take the protection of our copyright and licenses very seriously. If you
come across any illegal copies of our works, in any form, on the Internet, please
provide us with the location address or website name immediately so that we
can pursue a remedy.

Please contact us at copyright@packtpub.com with a link to the suspected


pirated material.

We appreciate your help in protecting our authors, and our ability to bring you
valuable content.

Questions
You can contact us at questions@packtpub.com if you are having a problem with
any aspect of the book, and we will do our best to address it.

[5]

www.allitebooks.com
Introduction to a Responsive
Web Application
In this chapter, we be introduced to responsive web design followed by an
understanding of technology stack that made responsive web application
development possible.

The current trend of technology revolution has led us to a point where we can
see many wireless devices with different screen size, resolution, and processing
capabilities. It is really challenging and difficult to create different versions of
web applications for each and every device type. To address this challenge,
it needs a design solution that can address these problems. Responsive web design
provides the platform and flexibility where we can write code once and publish the
application everywhere.

Designing a website to look good at one particular resolution was the standard and
that standard was adequate for almost all purposes. Now, more and more people
are viewing web content on smartphones and tablets. The most successful websites
must have content designed to fit on any size screen or any type of device. Designing
content in this manner is also known as responsive web design. We need to give
all users, regardless of their access platform, a seamless experience, and responsive
web design offers a cost-efficient way of achieving that. Responsive web content can
dynamically change size, fonts, and colors to match whatever device your customers
might be using.
Introduction to a Responsive Web Application

The most important dimensions of a responsive design are as follows:

• An adaptive grid-based layout that must be responsive enough to the


client-side environment. There are two different approaches for an adaptive
layout: the first one is a fixed layout and the other one is a fluid layout.
Fluid layouts are always proportional to the screen size.
• Fluid images must maintain the aspect ratio. To maintain the aspect ratio,
we can go for two approaches, either setting the max-height to 100 percent
or max-width of 100 percent. This makes the images overflow in either
direction. The other way of handling the images is to clip a portion of
the image, though it is not recommended.
• The new CSS3 media queries make the browser more intelligent.
Now, browsers can make the decision to load the appropriate CSS
at runtime. This makes them adaptable to the client environment.

Responsive design is made possible through the use of three core


ingredients: a flexible grid-based layout, flexible images and media,
and CSS media queries.

Benefits of a responsive design


The most important benefits of responsive web application are as follows:

• Pleasant user experience in each type of device


• Reduced development cost compared to developing different applications
for each device type
• Reduced cost on advertising and marketing compared to maintaining
campaigns for every application for each device
• Better indexing in search engines and improved search engine
optimization (SEO)
• Increased conversion rates and lead generation as SEO is increased
(visibility of a web application in search engines)

Responsive web design uses a single code base, but in reality, different devices have
to be accounted for. While a desktop version can display a lot of content at once,
for smaller screens, you need to know exactly what content truly matters. To create
a great experience for all users, you need to consider that people will use different
devices in different circumstances and with different goals. With a responsive web
design, more effort and time will be involved to get the right user experience for
your target audience.

[8]
Chapter 1

If you look into different applications present online such as blogs and sports
applications, then you will notice that the end user behaviors are similar and follow
a common pattern. To provide the same experience for the end users, the layout and
other elements in the application must be designed for customization. This needs
more effort and time in developing the layout and the code.

Server- versus client-side detection


Addressing the issue of developing applications for different media types and
devices can be solved in two ways. The first one is the server-side detection where
middleware is responsible for reading the request header sent by the browser and
redirects the request to the appropriate version of the application. This requires you
to develop a different version of the application. It means an e-commerce site must
have a separate code base for each type of device.

The second one is the client-side detection. It should be done by the browser and
apply relative CSS based on the device or screen type. With this idea, the responsive
design is born. The real benefit is that one has to maintain a single code base for this.

The technology stack


The following diagram shows the building blocks for responsive web application
development. Each block in the diagram represents a technology that enables
responsive web application development.

web Media
application queries

[9]
Introduction to a Responsive Web Application

HTML5
HTML5 is the latest version of HTML, released by the W3C foundation with more
modern features included such as more semantics and usability features. This helps
in responsive web application development with more ease and less effort. Some of
the key points that highlight why HTML5 is a better candidate than other versions of
HTML are as follows:

• Inclusion of new HTML5 elements such as video and audio as native reduces
the use of an additional third-party plugin
• Enhanced existing elements such as form element reduce the need for an
additional amount of code to be written
• Inclusion of Canvas and SVG for graphic rendering and drawing adds
additional capabilities

CSS3 and media queries


Features such as media type detection and layout manipulation of media queries are
useful to build a responsive layout. Some of the key points of CSS3 are as follows:

• CSS3 animations and transitions reduce the need for JavaScript processing,
favoring, instead, a native implementation that can vastly improve
performance on mobile devices where processing power can be quite
limited, while falling back gracefully to immediate changes in browsers
that do not support them.
• Support of new measuring units such as rem helps in building a logical
relationship among elements' dimensions present inside a page.
• Ultimately, the vw and vh units will greatly enhance the ability of a
developer to size elements relative to the viewport.
• FlexBox provides numerous benefits with direction-based alignment and
element ordering inside a layout. For a responsive design, this means that
a default ideal order can be established via the document order to provide
greater SEO benefits, while different ordering can be provided based on
viewport size, device orientation type, and so on, to display content in the
best format for a given use case.

[ 10 ]
Chapter 1

JavaScript
JavaScript brings the capability of feature detection for the browser. It helps in
choosing the right component for the end user and makes the browser responsive
to its environment.

Some of the key points about JavaScript are as follows:

• Browser feature detection helps you to find features that are supported
by the browser. This helps in helps you to execute the appropriate code
in the application.
• Rendering behavior of the site can be altered using JavaScript.

Measuring responsiveness
There are many parameters for measuring the responsiveness of an application.
Layout, content, and navigation are the three most important parameters for a
responsive web application development. The following diagram shows the three
different building blocks of a responsive web application:

•Element positions •Appearance •Page flow

• Layout: While developing a responsive web application for all kinds


of devices, the layout should be developed based on the available size.
Based on the breakpoints for each device size, the layout gets altered.
This includes show and hide of a section in the layout.
• Content: For small screens, the available viewing space is very small.
While developing a responsive web application, the text content must
be responsive. It includes the typography, images, and other media
elements present inside the page.
• Navigation: For touch-enabled devices, the navigational elements will
be different to those on medium devices. How these navigational items
are to be presented to the end user is really a design challenge. It should
be rendered seamless to the end user while navigating in any devices.

[ 11 ]
Introduction to a Responsive Web Application

Devices and screens


If you look at the gadget market for handheld devices, you can find a wide range of
devices with different screen sizes. If you ask me what the optimal size for a device
screen is, I probably could not answer you without knowing the purpose. Each and
every device is good for a specific use. So, the optimal size of a screen is directly
dependent on the end user.

A wide screen with good graphics and pixel density may be the best fit for a gaming
end user. For a regular end user, a small device is a good fit. The web application
design must support all these screen sizes. The usability and the user experience
must be equivalent to all types of screens. Also, it is much more important when it
comes to an e-commerce site. If the end user is browsing the site on a mobile device
and the e-commerce device is only designed for a desktop, then it does not generate
the same pleasant experience that will lose the leads.

The soul of an e-commerce site is lead generation and it is only possible when the
application will provide seamless access to the end user irrespective of the browsing
device. This clearly requires the application to be responsive to its environment or
adapt itself based on the screen or device.

Media types
All these devices (desktops, tablets, mobiles, and laptops) fall in one of the
following media types. The following figure shows all the media types listed
in the W3C specification:

[ 12 ]
Chapter 1

TV

Media
type

TTY

• Braille: This is used for braille tactile feedback devices.


• Embossed: This is used for paged braille printers.
• Handheld: This is used for handheld devices. Smartphones and tablets do
not fall to this.
• Print: This is used for paged material and for documents viewed on screen in
the print preview mode.
• Projection: This is used for projected presentations, for example, projectors.
• Screen: This is used primarily for color computer screens and smartphones.
• Speech: This is used for speech synthesizers.
• TTY: This is used for media using a fixed-pitch character grid. It includes
teletypes, terminals, or portable devices with limited display capabilities.
• TV: This is used for television type devices. It includes low resolution, color,
limited-scrollability screens, and audio.
• Grid: This is used for visual and tactile media types.

Available expressions for media queries to filter the CSS rules are as follows:

• width: This is the width of the current window


• height: This is the height of the current window
• device-width: This is the width of the device

[ 13 ]
Introduction to a Responsive Web Application

• device-height: This is the height of the device


• orientation: This should be either landscape or portrait
• aspect-ratio: This is the aspect ratio of the current window
• device-aspect-ratio: This is the aspect ratio of the device
• color: This is the number of color bits per color component
• color-index: This is the number of available colors on the device
• monochrome: This is the number of bits per pixel in a monochrome
frame buffer
• resolution: This is the resolution of the device
• scan: This should be either progressive or interlace

Media queries
Media queries are one of the best features of CSS3. Using this feature, we can decide
which style sheet should be applied on the web page at runtime.

Media queries can be used as external or internal style sheets. An external style sheet
is easier to organize; it is not downloaded by browsers that don't support it, but it
uses an extra HTTP request. An internal style sheet, on the other hand, does not
require an extra HTTP request, but the whole style sheet is downloaded for browsers
even if they do not support media queries, and it can be harder to organize.

The following code is an example of an external media queries call:


<link rel="stylesheet" type="text/CSS" media="screen and (max-device-
width: 480px) " href="abc.css" />

The following code is an example of internal media queries:


body {
background: gray;
}
@media all and (max-width: 480px){
body{
background: blue;
}
}

[ 14 ]
Chapter 1

Downloading the example code


You can download the example code files for all Packt books you have
purchased from your account at http://www.packtpub.com. If you
purchased this book elsewhere, you can visit http://www.packtpub.
com/support and register to have the files e-mailed directly to you.

Role of media queries


CSS3 provides a new set of features called media queries for responsive web
application development. These media queries are helpful for conditional CSS3 used
on a page based on the media type, device width, and other parameters. Generally,
the following parameters help in applying the correct CSS3 to the web page:

• Height and width of the device refers to the size of the device
• Height and width of the browser refers to the viewable area
• Screen resolution refers to the pixel and color depth of the screen
• Orientation of the device refers to the portrait or landscape mode

Using media queries, the layout can be designed in the following two ways:

• The adaptive layout: This is based on a pretty simple idea: instead of using
percentage, we will give our layout fixed sizes. The layout will adapt those
sizes depending of the width of the browser/viewport, thus creating a layout
with different breakpoints.
• The responsive layout: This is a mix between fluid and adaptive layouts.
It will use the relative units of the fluid layout and the breakpoints of the
adaptive one.

Responsive frameworks
There are many frameworks available from different vendors for responsive
web application development. Some of the popular libraries are explored in the
following sections.

[ 15 ]

www.allitebooks.com
Introduction to a Responsive Web Application

Bootstrap
Some of the key points about the Bootstrap framework are as follows:

• Twitter's Bootstrap library is the most popular responsive framework.


• It is based on mobile-first design strategy. The source code of the projects is
available in the SASS and LESS format.
• Bootstrap 3, SASS, and LESS really helps in customizing modules needed for
the project.
• There are many resources and plugins available on the Internet for the
Bootstrap framework.
• You can get more information from http://getbootstrap.com/.

The Foundation framework


Some of the key points about the Foundation framework are as follows:

• Foundation framework is yet another popular responsive framework


by ZURB foundation
• Foundation Version 5 follows mobile-first design strategy (designing your
site or app for the small device first, and then expanding that to include
larger displays and more full-featured devices)
• The major benefit of Foundation framework is that the rem unit is used
for its sizing of fonts and positioning
• You can get more information from http://foundation.zurb.com/

The Cascade framework


Some of the key points about the Cascade framework are as follows:

• The Cascade framework is lightweight and modular.


• The code packages in the Cascade framework are done based on
their features.
• For example, for coloring purpose, there is a color module to be invoked
and used. All features of Cascade framework support Internet Explorer
from IE6 upwards or degrade gracefully.

[ 16 ]
Chapter 1

• The whole library comes under four different modules: grid, typography,
icons, and components. It has also some reusable web page templates in a
different section.
• You can get more information from http://www.cascade-framework.com/.

The Pure CSS framework


Some of the key points about the Pure CSS framework are as follows:

• Pure CSS is a lightweight responsive framework by Yahoo Inc.


• The Pure CSS library is very tiny in size, and is about 4.4 KB minified and
compressed version. This library targets mobile devices.
• The core of this library is Normalize.css. The Normalize library provides
layout and styling of the HTML elements.
• You can get more information from http://purecss.io/.

The Gumby framework


Some of the key points about the Gumby framework are as follows:

• The Gumby framework is incredibly customizable


• It's as easy as download, tweak, and deploy
• Gumby is built on the SASS authoring framework
• Most eye-catching features in Grid modules such as Basic Grid, Hybrid
Grid, Nested Grid, Sematic Grids, Tiles, and Fancy tiles are part of the
Gumby framework
• You can get more information from http://gumbyframework.com/

Bootstrap 3 for a responsive design


There are many components and utilities available for responsive web application
development in Bootstrap. Bootstrap features are available in the following three
different modules:

• CSS: This module has a lot of standard classes to use and is easily extendable
for customization
• Component: This module has all the reusable built-in components
• JavaScript: This module has the jQuery plugin in Bootstrap style

[ 17 ]
Introduction to a Responsive Web Application

Some important features that we are going to use in our web application
development are presented in the following diagram:

Responsive HTML5 Helper JS


Grid layout
utilities elements classes components

• Grid layout: This module has different grid classes for xs, sm, md, and lg
type devices. The details of these grid classes are listed as follows:
°° xs stands for extra small devices. For example, a phone's screen
resolution is less than 768 pixels.
°° xm stands for small devices. For example, a tablet's screen resolution
is greater than or equal to 768 pixels.
°° md stands for medium devices. For example, a desktop's screen
resolution is greater than or equal to 992 pixels.
°° lg stands for large devices. For example, a desktop's screen resolution
is greater than or equal to 1200 pixels.

• Typography: This module has different classes based on the font


size requirements.
• Responsive utilities: This module contains classes for conditional classes
based on the types of devices.
• HTML5 elements: This module has default style classes for all
HTML5 elements.
• Helper classes: This module has classes for frequently used alignment and
positioning issues.
• JS components: This module has additional components such as carousel,
tooltip, popover, and so on.

What are we building?


We are going to use the Bootstrap 3 framework for responsive web application
development. In the following chapters, we will build an e-commerce web
application that will be responsive in design.

[ 18 ]
Chapter 1

The plan is as follows:

• Building the layout for the application


• Populating the content in the layout
• Integrating the application with social media sites
• Integrating a payment system with the Add to Cart feature
• Building a currency converter
• Debugging and testing the web application for responsiveness

Summary
In this chapter, we have learned about the need for a responsive web application
and what challenges it brings to a web developer. We have also learned about the
latest responsive libraries available for development. We have understood how
a responsive layout can increase the user experience. In the following chapter,
we will learn to develop a responsive layout using CSS3.

[ 19 ]
Creating a Responsive
Layout for a
Web Application
In this chapter, we will set up our Java-based web project and develop the layout
required to create our responsive web application. The process of developing the
layout follows a step-wise approach. Initially, we will draw a wireframe for the
layout, and then, we will prepare code for each section using Bootstrap 3 classes.
Later on in this chapter, we will verify the layout with different screen sizes
using some tools.

Required software and tools


We need the following software to be installed to develop the responsive
web application:

• An Eclipse Java EE IDE of Juno/Kepler version for web developers


(http://www.eclipse.org)
• Apache Tomcat 7
• Opera Mobile emulator
• The draw.io online tool
• The Mozilla Firefox browser
• The Google Chrome browser
Creating a Responsive Layout for a Web Application

Setting up a Java-based web project


In this section, we will set up a Java-based web project in Eclipse. To do this, we have
to create a new dynamic web project. The following screenshot shows the window to
create a new web project. In Eclipse, click on the File button and choose New to list
the different project types present in Eclipse.

The different available project types present are shown in the following screenshot.
When this window appears, choose the Dynamic Web Project option.

[ 22 ]
Chapter 2

When you have chosen the Dynamic Web Project option, a New Dynamic
Web Project window will open asking for Project name, as shown in the
following screenshot:

[ 23 ]
Creating a Responsive Layout for a Web Application

For our application, we will name the project MyResponsiveWebApp. The project
structure will look like the following screenshot:

The WebContent folder consists of all the HTML, CSS, and JavaScript files.
The Navigator view of this empty project will look like the following screenshot:

[ 24 ]
Chapter 2

Configuring Bootstrap 3
In this section, we will configure the Bootstrap 3 library in our web project.
Download the Bootstrap 3 library from http://getbootstrap.com/getting-
started/#download. Bootstrap 3 has three different folders in its distribution
package. They are explained as follows:

• js: This folder contains all the scripts required for the Bootstrap 3 library
• fonts: This folder contains all the font-related files including the Glyph icons
• css: This folder contains all the style sheet-related files with Bootstrap's
default theme

The following figure shows the structure of the Bootstrap 3 library:

dist js

[ 25 ]

www.allitebooks.com
Exploring the Variety of Random
Documents with Different Content
was beautiful, rational, and practicable; and that he was persuaded
his M――y would highly approve of, and also favour it, with some
peculiar marks of his royal bounty.” At their desire I went to town,
and dined with him and the G――r at Savannah. On Tuesday next,
God willing, I move towards Charles-Town, leaving all arrears paid
off, and some cash in hand, besides the last year’s whole crop of
rice, some lumber, the house repaired, painted, furnished with plenty
of cloathing, and provision till next crop comes in, and perhaps some
for sale. Messrs. D――n, S――k, and their wives, stay till my
successors come to supply their places. Only a few boys will be left,
and two of them are intended for the foundation. So that this year
they will be getting rather than expending. Near ten, boys and girls,
have been put out, and the small-pox hath gone through the house,
with the loss of about six negroes and four orphans. Before which, I
think not above four children have been taken off these twenty-four
years. As an acknowledgment of Mr. and Mrs. D――n’s faithfulness
and care, I have made them a present of a bill of exchange drawn
upon you. It is for Jesus, who shed his dear and precious blood for ill
and hell-deserving me. And now it may be, I may see England this
summer. But still I cry, who shall roll away the stone? Jesus will do it
for me. And now farewel, my beloved Bethesda; surely the most
delightfully situated place in all the southern parts of America. I do
not forget your dear relations. What a blessed winter have I had!
Peace, and love, and harmony, and plenty, reign here. Mr. W――t
hath done much in a little time. All are surprized at it. But he hath
worked night and day, and not stirred a mile for many weeks. Help,
help, my dear English friends, to pray me over, as being, for
Christ’s sake, my very dear Sir,

Ever yours, theirs, &c. &c.

G. W.

LETTER MCCCXXV.
To Mr. R―― K――n.

Savannah, February 18, 1765.

My very dear Friend,

Y ESTERDAY we had a most cutting parting at Bethesda; but


blessed be God, for giving me to part from it in such
comfortable circumstances! All arrears are paid off, cash, stock, and
plenty of all kinds of provision before-hand, and under God, no
danger, at least for this year, of going back; so that one great load is
taken off. What shall I render unto the Lord of all Lords for this and
all other his mercies?

Praise God, my soul, even unto death,

And raise a song with every breath.

And now my thoughts turn toward England. As a proof of it, I have


sent a box in the Friendship, Captain Ball, directed to you. The
things in the box, for the most part, do belong to Mr. W――t, and all
of them, if I die in my way to England. That will be a blessed voyage
indeed! Brethren, pray for us, pray for us; and assure yourselves of
being never forgotten by, my dear old friend,

Yours, theirs, &c. in everlasting bonds,

G. W.

LETTER MCCCXXVI.
To Mr. and Mrs. D――n.

Charles-Town, March 5, 1765.


My very dear dear Friends,

O FTEN have we thought, and talked of, and if it was lawful,


wished ourselves at Bethesda again. No place like that for
peace, and plenty of every kind. May this find you all enjoying God,
and each others company, in a manner the world knows not of! It
leaves me in my poor way, aiming to do a little for Him, who hath
done and suffered so much for ill and hell-deserving me. People of
all ranks fly to the gospel like doves to the windows. The word
begins to fall with great weight, and all are importunate for my longer
stay. But next week I expect to move. Captain M――r, though waited
for near two months, is not yet arrived; Mr. S――n’s Lady comes
with him, when you may expect a more particular letter. He sets off
for Georgia immediately upon his Lady’s arrival. The negroes shirts,
&c. are in hand. O that those Ethiopians may be made to stretch out
their hearts unto God! I feel a great compassion for them. Letters
from the northward, give sweet accounts of the spreading of the
work of God; but I must not enlarge. So many various calls surround
me, that I have scarce leisure to dispatch my private business. God
bless you! God bless you all in soul and body, in time and eternity!
The parting here hath been most affecting and awful. Several
presume to prophesy, that I shall certainly and speedily see South
Carolina, and my beloved, dearly beloved Bethesda again. I say
heartily, Amen! What say you? I shall not wait for an answer. If the
Lord Jesus say amen too, it will do. And now for the present, adieu.
God bless you, and fill you all with all his fulness! Pray hard for us;
pray, if possible, that the glorious Emmanuel would give me to see
these parts once more. A blessed work, I trust, is begun. Grace,
grace! Perhaps this is not a parting letter. You may hear from me
more minutely by the Chief Justice; but who knows what a day may
bring forth! A―― H――’s wife died suddenly, a few days before my
return hither. Others taken, and I still left. Lord Jesus, quicken my
tardy pace! On Friday next, God willing, I shall read prayers and
preach in Ashby-Ferry church. Mr. Z――y hath preached well here.
Dear, very dear friends, continue to pray for me. Indeed I pray for
you night and day; and, God willing, this shall be the constant
employ of, my very dear, very dear friends,
Ever yours, &c. &c. &c. in Jesus,

G. W.

LETTER MCCCXXVII.
To Mr. S―― S――.

Charles-Town, March 15, 1765.

My very dear Friend,

H ITHERTO the Lord hath helped: I have had a most pleasant


winter. The inclosed will shew you in what a situation I left
Bethesda. To put the finishing stroke to that affair, I fear I must
embark for England. Well may I say I fear; for indeed words cannot
well express what a scene of action I leave behind. Alas! my
American work seems as yet scarce begun. My health is better, and
every day the word of God runs and is glorified more and more. In
two days, my wilderness range commences afresh. In about six
weeks I hope to see Philadelphia. From thence, they say, I am to set
sail for my native country. But heaven! a blessed, long wished-for
heaven, is my home. Surely, death will say by and by, “Come up
hither.” This, I trust, will find you and yours mounting aloft. God bless
you, and all your connections! Indeed and indeed I owe you much,
very much love. As a pepper-corn of acknowledgment, be pleased to
accept these few loving lines from, my very dear friend,

Ever yours, &c. &c. &c. in Jesus,

G. W.
LETTER MCCCXXVIII.
To Mr. R―― K――n.

Wilmington, Cape-Fear, March 29, 1765.

My very dear Mr. K――,

T HUS far the Lord hath brought me in my way to Philadelphia,


from whence, according to the present scheme, I purpose to
embark for England. But I sometimes doubt, whether it is right or not.
However, this is my comfort, that I serve a master who will not suffer
the blind, that desire to know and do his will, to go out of their way.
Hitherto he hath made the wilderness to smile! We had a most
cutting parting from Charles-Town. I preached thrice in my way to
this place. At the desire of the Mayor and other gentlemen, I shall
stay till next Sunday, and then purpose, God willing, to go on my
way. Indeed and indeed, this pilgrimage kind of life, is the very joy of
my heart. Cieled houses and crouded tables I leave to others. A
morsel of bread, and a little bit of cold meat, in a wood, is a most
luxurious repast. Jesus’s presence is all in all, whether in the city or
the wilderness. I hope that you and my other dear metropolitan
friends, in the midst of all your noise, are always hearing that small
still voice that whispers, “Love.” I think much of the late trial of my
never to be forgotten friends at Cannonbury-house. Remember,
according to promise, you will be kind enough to act as trustee, and
all things are to continue just as they are, if it should please God to
bring me to London. Now I am free, God keep me so for Christ’s
sake. Tender love to all. I send them most cordial salutations, and
intreat the continuance of their and your prayers, in behalf of, my
very dear Mr. K――,

Theirs and yours most affectionately in our never-failing


Emmanuel,

G. W.
LETTER MCCCXXIX.
To Mr. R―― K――n.

Newcastle, 30 miles from Philadelphia,


May 4, 1765.

My dear Mr. K――n,

I AM just come here, in my way to embark from Philadelphia. But


how shall I do it? Every where the door opens wider and wider.
All along, from Charles-Town to this place, the cry is, “for Christ’s
sake stay and preach to us.” O for a thousand lives to spend for
Jesus! He is good, he is good! His mercy endureth for ever. Help,
help, my dear English friends, to bless and praise Him. The letters by
Captain Ball, I hear are sent from Charles-Town, in my trunk, to
Philadelphia. I expect to receive them this evening. Thanks be to
God, all outward things are settled on this side the water. The
auditing the accounts, and laying a foundation for a college, hath
silenced enemies and comforted friends. The finishing this affair
confirms my call to England at this time. But I have no manner of
prospect of being able to serve the tabernacle and chapel. I cannot
preach once now, without being quite exhausted. How then shall I
bear the cares of both those places? But I must beg you and dear
Mr. H――y to continue trustees when I am present, as well as in my
absence. I wish that a ship was ready now, perhaps I may yet sail
from New-York. I am praying night and day for direction. The word
runs here, and is glorified. But the weather, for two days, hath been
so hot, that I could scarce move. To-day it is much cooler. I dread the
shaking of the ship. But if it shakes this tottering frame to pieces, it
will be a trading voyage indeed. As Mr. Blake is not mentioned in
your last, I hope he is recovered. Death will do this for us all. Blessed
be God, for enabling young Mr. Beckman to face it so triumphantly!
This must be a great cordial to the afflicted parents. That they, your
dear relations, and all my tried friends, may be comforted yet more
and more, is the earnest prayer of, my very dear Sir,

Yours, theirs, &c. &c. in Jesus,

G. W.

LETTER MCCCXXX.
To Mr. D――n.

New-York, June 6, 1765.

My very dear Friends,

A CCEPT a few loving parting lines. Next Sunday, God willing, we


sail in the Earl of Halifax packet. No ship offered at
Philadelphia. I am almost too weary to write. Jesus made the
wilderness to smile! Grace! grace! I have received letters from
England, dated April 13, in answer to those sent from Georgia. All
say, you must come, or Bethesda affairs cannot be finished. Expect
the first intelligence after my arrival. In the mean while, cease not to
remember us at the throne of that Jesus; in whose great name, I
desire to subscribe myself, very dear dear friends,

Ever yours, &c. &c. in Jesus,

G. W.
LETTER MCCCXXXI.
To Mr. R―― K――n.

Plymouth, July 12, 1765.

My dear dear Mr. K――n,

P ERHAPS I am arrived a little before the expected time. We have


had but a twenty-eight days passage, in the Hallifax packet,
from New-York, which got into Falmouth last Monday. I left the
vessel near the Lizard, and by the blunder of a drunken fellow,
missed the Post on Monday evening. The transition hath been so
sudden, that I can scarce believe that I am in England. I hope, ere
long, to have a more sudden transition into a better country. Come,
Lord Jesus, come quickly! I want a gown and cassock. Child, in
Chancery-Lane, used to make for me, and perhaps knows my
measure. Amazing, that I have not been measured for a coffin long
ago! Lord Jesus, thy will be done! I am very low in body, and as yet
undetermined what to do. Perhaps, on the whole, it may be best to
come on leisurely, to see if my spirits can be a little recruited. You
may write a few lines at a venture to Bristol. dear Mr. H――y shall
hear more particularly the next Post, whatever rout I take. Had I
bodily strength, you would find me coming upon you unawares; but
that fails me much. I must have a little rest, or I shall be able to do
nothing at all. Let no one stir to meet me, it being uncertain what rout
I shall take. The Lord Jesus be with all your spirits! Ten thousand
thousand thanks await you and your dear collegue, and all your dear
friends, for all assistance given to, my dear dear friends,

Ever yours, &c. &c. in Jesus,

G. W.
LETTER MCCCXXXII.
To Mr. R―― K――n.

Bristol, July 18, 1765.

My very dear Friend,

J UST now, with great joy, I received your welcome letter, I fear the
post will be gone, ere this can be put in. Blessed be God, I am a
little better. I have a fine commodious house, and am kept from
much company. You will certainly know my rout. Indeed and indeed, I
long to see my dear Mr. K――n, and my dear Mr. H――y. Stand, my
friends, and insist upon my not being brought out into action too
soon. The poor old shattered bark hath not been in dock one week,
for a long while. I scarce know what I write. Tender love to all.

Ever yours, &c. &c. in Jesus,

G. W.

LETTER MCCCXXXIII.
To Mr. E――s.

London, August 3, 1765.

Dear Mr. E――s,

IAM very weak in body, but gratitude constrains me to send you a


few lines of love unfeigned, for your labours of love during my
absence abroad. I rejoice to hear they were blessed. Our friends tell
me, that the sound of your Master’s feet was certainly heard behind
you. To Him, and Him alone, be all the glory! Is not this
encouragement, my dear brother, to go on, and to be instant in
season and out of season? If God will work, who shall hinder?

Give us thy strength, O God of power,

Then let winds blow and thunders roar:

Thy faithful witnesses we’ll be;

’Tis fix’d! we can do all through thee.

Thanks be to God, we do not go a warfare on our own charges; the


Captain of our salvation will conquer for and in us. Let us but
acknowledge him in all our ways, and He hath given us his royal
word, that “He will direct and prosper all our paths.”

Fix on his work our stedfast eye,

So shall our work be done.――

Our enemies shall be at peace with us, and the very ravens, birds of
prey, shall be obliged to come and feed us. O for an increase of faith!
I hope you have refreshing times from the presence of the Lord,
among your own flock. May grace, mercy, and peace, be multiplied
amongst you! If the common interest of the Redeemer be promoted,
I rejoice, yea and will rejoice. My earnest prayer is, that you, and all
that labour in our Lord’s vineyard, may more and more be taught to
give every one their portion of meat in due season; and may your rod
blossom more and more! O to end life well. Methinks I have now but
one more river to pass over, Jordan. And we know of one that can
carry us over, without being ankle deep. How are Messrs. G――th,
A――ge, &c. &c. S――k and his wife send cordial salutations. I left
them labouring on their Bethesda plan, till the intended college is
established. Yet a little while, and all true labourers shall enter into
the joy of their Lord. Amen! Hallelujah! Cease not to pray for, dear
Mr. E――s,
Yours, &c. in the blessed Jesus,

G. W.

LETTER MCCCXXXIV.
To Mr. D――n.

London, September 6, 1765.

My very dear Friends,

I AM sorry that matters have been so ordered, as to confine you so


long at Bethesda. But you have learned to believe, that the
Redeemer orders all things well. Soon after my arrival, Lord D――h
was put at the head of the board of trade. This will soon bring
Bethesda affairs to a speedy issue. You will then be released. But
indeed and indeed, in my judgment you had best keep where you
are. You will soon repent coming over. Mrs. R――l, whose husband
is lame, is utterly against your coming. But you must follow your own
judgment. Though people flock more and more, and my health is
better, yet I make no secret of it, that my heart is abroad. Mrs. R――l
tells me strange things of B――y, and disagreeable things of
P――y. O my God! shall I have no prize tickets amongst those I
would willingly serve! Well,—the faithful nurse shall be paid, whether
the child lives or dies. You therefore shall verily have your reward.
Excuse enlarging. Captain Gunn goes to-day. Mr. Wright sends
cordial respects. My wife is gone for a little while into the country.
God bless you! God bless you! More opportunities of sending will
soon offer to, my very dear friends,

Ever yours, &c. &c. in our glorious Head,

G. W.
LETTER MCCCXXXV.
To Mr. A―― K――n.

London, September 20, 1765.

My dear Timothy,

P RAY when are we to have the honour of a visit from you? I


believe more than three weeks are elapsed since you came to
Bristol. Mr. Adams is to be your collegue here. I purpose for both of
you to preach at the chapel, as well as at the tabernacle. Write an
immediate answer, fixing your time of coming; and you must not
think of returning soon. Mr. Middleton sends me word, that he is
blessed at Plymouth, and especially at dock, and that Kingsbridge
christians are lively. I hope it is so at Bristol. Blessed be God, it is
pretty much so in London. Lord Jesus, quicken my tardy pace!
Through his never-failing mercy, I have been better in health for a
week past, than I have been for these four years. O for a thankful
and an humble heart! My wife also returned well, last night, from
Bury. She indulges this morning, being weary. But I take it for
granted, that you and I rise at five. Mr. Adams’s room will be large for
you to breathe in. I shall never breathe as I would, till I breathe in
yonder heaven.

There sin and strife and sorrow cease,

And all is calm and joy and peace.

Adieu. Cordial love awaits all where you are, all at tabernacle house,
and all that are so kind as to pray for, and enquire after, my very dear
Timothy,

Yours, &c. &c. in our glorious Emmanuel,


G. W.

LETTER MCCCXXXVI.
London, September 28, 1765.

My very dear Timothy,

T HOSE that are Timothies indeed, shall be honoured of Him,


whom they desire to honour, with a disinterested spirit. I am
glad you find old Jacob’s prophecy to be fulfilling. “To Shiloh shall the
gathering of the people be.” Nothing is wanting at Bristol, London,
and elsewhere, but labourers full of the first old methodistical spirit.
But where to get them is the question. Those that are thus minded,
are almost worn out. I would gladly fly to Bristol if I could; but I see
that it is best to be here for some time. And indeed, things have
always been at such a low ebb, when I have been at Bristol, and
matters carried on with so little spirit, that I have generally come
mourning away. If a few, such as Mr. C――t, would exert themselves
steadily, and perseveringly, and proper preachers were sent,
something might be done to purpose. But as neither of these things
is likely to happen, my expectations are not very much raised.
However, the residue of the spirit is in the Redeemer’s hands. Our
eyes wait upon Him. From Him, and Him alone, all kinds of salvation
do come. Fain would I have you up at London for some time, at this
season. Mr. D――r expects to see you in a clerical habit about
Christmas. He asked me, if I would get him a scarf? I answered, that
you must have one first. You may guess how he smiled. However, I
really intend you shall preach in the chapel. I want you also to read
the letters, and give me leave to comment upon them, as my breath
will allow. You may return by way of Bristol, or if Sarah is worse, go
from hence. I thank you heartily for making the collections. Never
was a cause kept up at such a small expence; “not by might, or by
power, but by my spirit, saith the Lord.” This be our invariable rule.
God bless and prosper you more and more. If I have not tired you, I
have almost tired, my very dear Timothy,

Yours, &c. &c.

G. W.

P. S. Since writing the above, I find providence calls me to Bath,


to open good Lady Huntingdon’s chapel. God willing, I purpose to
set out next Tuesday. You must set out for London the same day;
otherwise, it may be, Bristol people will not see me. Adieu. Your
preaching orders, as to time and place, you will receive at your
arrival. That you may do Satan’s kingdom much hurt, is the hearty
prayer of, my very dear man,

Ever yours, &c. in our common Lord,

G. W.

LETTER MCCCXXXVII.
To Mr. R―― K――n.

Bath, October 7, 1765.

My very dear Friend,

W HAT a providence (as matters have fallen out) that your Bath
journey was prevented! Could you have come, and been
present at the opening of the chapel, you would have been much
pleased. The chapel is extremely plain, and yet equally grand. A
most beautiful original! All was conducted with great solemnity.
Though a very wet day, the place was very full, and assuredly the
great Shepherd and Bishop of souls consecrated and made it holy
ground by his presence. I preached in the morning, Mr. Townsend in
the evening. Expect more particulars when we meet. My moving
depends on Mr. M――n’s punctuality. I am to preach to-morrow
night, and have hopes of setting off on Wednesday morning. God
give us all grace to work whilst it is day! The time of sickness and
lowness comes, when no man can work. Dear Miss H――y is
happily fled from all. Happy, happy she. God comfort all surviving
relatives. They, as well as you and yours, are never forgotten by, my
very dear Sir,

Yours, &c. &c. in Him who is all in all,

G. W.

LETTER MCCCXXXVIII.
To Mr. D――n.

London, October 26, 1765.

My very dear Friend,

A CCEPT a few hasty but loving lines. Your letters came safe. I
thank God for their contents. In return I can inform you, that
Bethesda matters are likely to come to a speedy and happy issue.
We talk of my coming over again. It is not impossible, if my health
admits. At present, blessed be God, I am better than last year. The
word runs and is glorified in London. Bet D――y must not come
here. You have not been so explicit as was Mrs. R――l about her.
Instead of her, pray send over a barrel of rice or two, directed to Mr.
T―― C――a, in Winchester-street, near Moorfields. Pray inform Mr.
H――m, that I hope to send him some pleasing particulars by the
next ship. I have much to say, but have scarcely a moment left to
send you my hearty thanks and blessing, and subscribe myself, my
very dear friend,
Ever yours, &c. in the glorious Emmanuel,

G. W.

LETTER MCCCXXXIX.
To ――, at Sheerness.

London, January 18, 1766.

Dearly Beloved,

N OT want of love, but of leisure and health, hath occasioned you


the trouble of writing a second letter. And now I am sorry to
acquaint you, that it is not in my power to comply with your request.
For want of more assistance, I am confined in town with the care of
two important posts, when I am only fit to be put into some garrison
among the invalids, to stand by an old gun or two. However, my
former ambition still remains, and through the help of your prayers,
who knows but this feeble arm may yet be strengthened to annoy the
enemy? If others are blessed to do any execution, God forbid that I
should hinder, though in all things they follow not with us. Let the
Lord send by whom he will send. So that Christ is preached, and
true evangelical holiness promoted, I rejoice, yea and will rejoice.
God keep us all from flagging in the latter stages of our road! Lord
Jesus, quicken my tardy pace! How little, my Lord and my God,
have I done for thee, who hast done and suffered so much for ill and
hell-deserving me! Brethren, pray for us. Ere long we shall meet

Where sin and strife and sorrow cease,

And all is calm and joy and peace.


He is faithful who hath promised, who also will do it. Amen!
Hallelujah! To his never-failing mercy do I commend you, as being,
for his great name’s sake, dearly beloved,

Your affectionate friend and willing servant,

G. W.

LETTER MCCCXL.
To Mr. R―― K――n.

Bristol, March 17, 1766.

My dear Mr. K――n,

T HE uncertainty of my motions hath made me slow in writing, and


a desire to be a while free from London cares, hath made me
indifferent about frequent hearing from thence. In a day or two, I
hope matters will be determined. If Mr. S――d comes, I have a mind
to stay a little longer; and if dear Mr. Howell D―― will continue to
officiate, I have a mind to visit Wales for him. Last Friday evening,
and twice yesterday, I preached at Bath, to very thronged and
brilliant auditories. I am told it was a very high day. The glory of the
Lord filled the house. To-morrow, God willing, I return thither again.
Mr. T――d is too ill to officiate. If any urgent business requires, be
pleased to direct either to this place or Bath. Pray shew my wife this.
I hope no news is good news. I trust that the holy Spirit is moving in
Mr. ――’s family, both on the heads and the servants of it. Many do
think old times are coming round again. Pray tell Mr. W――r, that I
think the letters he hath sent need not go to Scotland as yet. I sent a
packet thither last week. This I write in the midst of company. Lady
H――n is mounting on her high places. I wished my two steady
friends at Bath yesterday. Mr. S――t hath met with a great blessing.
Pray, pray for us. All send due respects. Tuesday or Wednesday
next I hope to write again to my wife. Cordial respects and love
attend her, your whole self, dear Mr. H――y and sisters, Mr. Howell
D――, and all that are so kind to enquire after and pray for, my dear
Sir,

Theirs, yours, &c. &c. in our never-failing Jesus,

G. W.

LETTER MCCCXLI.
To the Reverend Mr. G――.

London, April 25, 1766.

Reverend and very dear Sir,

N OT want of love, but of leisure and better health, hath prevented


your hearing from me more frequently. I find I cannot do as I
have done. But, through infinite, free, and sovereign mercy, I am
enabled to ascend my gospel throne three or four times a week, and
a glorious influence attends the word. People have indeed a hearing
ear, but we want more preachers. I know the continual cry of your
heart is, “Lord, let thy kingdom come.” The prospect of a large and
effectual door opening among the heathen, blessed be God, is very
promising. Mr. Occum, the Indian preacher, is a settled humble
christian. The good and great, with a multitude of a lower degree,
heard him preach last week at Tottenham-Court chapel, and felt
much of the power and presence of our common Lord. Mr. R――n
hath preached, and collected a hundred pounds, and I believe seven
or eight hundred pounds more are subscribed. The truly noble Lord
D――h espouses the cause most heartily, and his Majesty is
become a contributor. The King of kings and Lord of all lords will
bless them for it. O what an honour to be permitted to do or suffer
any thing for Jesus of Nazareth! Indeed and indeed, I want to begin
to begin: for hitherto, alas! I have done nothing.

Whene’er you see a barren tree,

Then, O my friend, pray think of me.

Lord Jesus, make me willing to be made willing that thou shouldst


dig and dung around me, that I may at length bring forth some fruit
unto thee. However it may be with unprofitable, ill, and hell-deserving
me, I trust your whole self and all my other dear G―― friends are so
grown as to become tall cedars in the spiritual Lebanon. I pray for,
though I cannot write to them. Hearty, special love attend my dear
host, and his yoke-fellow. If possible they shall hear from me soon. I
hope all is well at Cambuslang. Blessed be God, all will be well in
heaven. Yet a little while and we shall enter into perfect rest. He that
cometh will come, and will not tarry.

We soon shall hear th’ archangel’s voice;

The trump of God shall sound, Rejoice!

I will not interrupt you. You want to say, Amen! Hallelujah! I only add,
when upon the mount, put in a word for an old friend, who retains his
old name, the chief of sinners, less than the least of all saints, but for
Jesus Christ’s sake, reverend and very dear Sir,

Your willing servant,

G. W.

LETTER MCCCXLII.
To W―― P――, Esq.

Tottenham-Court, May 15, 1766.

T HOUGH at present in almost a breathless state, by preaching for


the best of Masters last night, yet a weak worm hopes to be
strengthened to give the holy sacrament at seven next Sunday
morning, and, if able, to preach afterwards at ten. If good Mr. R――
and Lady will come at near seven to the chapel house, they shall be
conducted to a proper place. I wish them a Pentecost, not only on
Whitsunday, but every day, every hour, and every moment of their
lives. Our privilege, as christians, is not to be afraid of, but looking
towards, and waiting for the coming of the Son of God. He expects
that our lamps should be trimmed, our loins girded, and our lamps
burning. There is oil enough in him, our glorious Aaron, to keep them
so. It runs to the very skirts of his garments, even to the least
member of his mystical body, and therefore to the heart and soul of,
dear happy pair,

Your most willing servant for Jesus Christ’s sake,

G. W.

LETTER MCCCXLIII.
To W―― P――, Esq.

Tottenham-Court, June 2, 1766.

W HAT a mercy, that God’s elect, knit by the blessed Spirit, (that
common centre of unity) in one communion and fellowship,
can, though absent, be present with each other on earth! What an
infinitely greater mercy, that they are assured they shall meet never
to part again in heaven! This may reconcile them to all interruptions
of mutual concern here below. My cloud seems to point towards
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like