Improvement of Single Page Application in responsive design using Web API and AngularJS
427
Published By:
Blue Eyes Intelligence Engineering
& Sciences Publication
Retrieval Number: ES2077017519/19©BEIESP
This has several advantages. First of all, an initial page is
now rendered faster since a smaller amount of data is
transferred to the user. This is the case since every request
does not have to include the presentation of the data. It also
allows data to only be fetched one single time since the client
now can act as a small cache memory of the database. All of
this flexibility leads to a more responsive interface and in the
end to a better user experience. Unfortunately this flexibility
also comes with a price, the frontend is now a lot more
complex than before. When the frontend grows, testability
becomes a critical issue. In order to build a high quality
application, the developers must be able to test the
components of the system. An architecture that allows a high
degree of testability is needed.
Since data is represented both at the client and at the
backend side an interface is needed for the communication in
between. This interface needs to be implemented, for purpose
of fetching, inserting, updating and deleting data. Problems
regarding synchronization between user sessions may also
arise since the client now acts as a cache memory to the
database. When a user modifies data this may affect other
users that are online, i.e. concurrency problems can appear.
The responsibility of synchronization between users is now
put on the developer. All of this leads to a more complex
design of the frontend.
When the frontend becomes bigger and more complex it
also requires more memory to run. Since a user often only
works with a particular part of a system at a time, it would be
a waste of memory to have the entire application instantiated.
A structure that allows the developer to decide what parts of
the system to run would solve this problem. If the design of
these parts of the system could also be re-used in other
applications, then the efficiency of the development would be
greatly increased. Another important aspect of software
development is maintenance of the code. In bigger
applications several developers are often working
collaboratively to build the frontend of a system. Code that is
easy to read and understand becomes a key to achieve high
efficiency and good quality. The use of design patterns
becomes an important part of the system design.
Unfortunately, it is a complex choice to make since there are
many aspects to consider.
Some criticism has been raised against the performance of
SPAs in terms of initial loading time. Due to limitations of the
HTTP architecture the initial loading time might be higher
when using a JavaScript frontend compared to the traditional
approach. This is the case since the client first downloads the
initial page and then executes its JavaScript. When this is
done the user can be routed to the corresponding page and its
content can be loaded. This leads to a higher initial loading
time compared to just downloading the plain page from the
server. However, once the initial page has been loaded and
rendered the JavaScript frontend will be able to perform a lot
better. Since the initial loading time is a key factor when a
user is deciding to visit a site or not, it has become a crucial
aspect of JavaScript-based frontends.
Another problem that is introduced when building a
frontend in JavaScript is that if users visit the site and have
disabled or cannot run JavaScript, then they will not be able to
see the content of the site. Even though only 2% of today’s
users have
JavaScript disabled this still represents a problem.
Crawlers from search engines represent for example a small
amount of the total number of users but they are still very
important to consider. If a crawler cannot see the content of
the page it is impossible for it to analyse what the site is all
about. This would lead to a poor page rank at the search
engine. For many of today’s websites this is extremely
important.
The goal of the paper is to come up with a system design of
a framework for more lightweight single-page applications.
The architecture shall be based on design patterns well suited
for web frontends. To give a good view of how design
patterns can be used in practice the project clarifies how they
can be typically used in a web application. Based on the
analysis at the system design stage the framework
isimplemented, allowing applications to get a high degree of
testability as well as encouraging code re-usage between
projects. The initial loading time of the page is considered as
an important aspect of the framework and my work aspires to
provide a shorter loading time compared to existing
frameworks. The paper also proposes a solution to the
problem of search engine optimization for single-page
applications.
By looking at design patterns suitable for graphical
interfaces an abstract idea of how to form the system
architecture was developed. This idea was then further refined
to fit a structure that was more suitable for the web. Today
there already exists a number of JavaScript frameworks, these
were analysed so that different ways of approaching the
problems could be found. The majority of the existing
frameworks are using techniques that are well known, well
tested and have a wide browser support. However, the
upcoming HTML5 draft [6] contains new exciting techniques
introducing new ways of approaching the problems. These
techniques were taken into account when designing the
architecture of the framework. During the design phase
suitable design patterns were selected for the upcoming
implementation of the framework. To be able to design the
framework with a high degree of testability a test framework
for JavaScript was used. It was important to understand how
testing typically is carried out and what testing utilities that
are commonly used. Once the system design was ready the
framework was implemented.
To verify that the project fulfilled its requirements a simple
test application was developed. This application was built
upon the framework in JavaScript. The purpose was to
demonstrate how a developer could use the framework and
how the most common problems are solved. Finally the initial
loading time and testability were verified by performing a
number of tests. The results were then be compared against
other competitors.
As previously described SPAs introduce new demands
regarding architecture and structure on the client side. To
understand how these problems can be approached it is
important to understand the basics behind how a single-page
application works [5,6].