Chapter 5. Refactoring Our Site

"Welcome to the code!"

Now, before continuing, we will try to refactor our site a bit. This is going to be a small chapter, where we will take a look at our site, modify it, and learn a bit more about how it works.

But what is all this refactoring about? Well, Wikipedia (http://en.wikipedia.org/wiki/Code_refactoring) says:

"Code refactoring is the process of changing a computer program's source code without modifying its external functional behavior in order to improve some of the nonfunctional attributes of the software. Advantages include improved code readability and reduced complexity to improve the maintainability of the source code, as well as a more expressive internal architecture or object model to improve extensibility."

So that's what we are going to do, try to make our code better without changing how our site looks. At this moment we are using quite a good number of third-party extensions in our site. We all must agree that the creators of these extensions have done a great job, and that all of these extensions have helped us in preparing a great site.

However, we have a little problem here; each one of these extensions is loading their required libraries. In most cases these include the jQuery library.

It's necessary to load these libraries, as the creators behind these extensions don't know if the required libraries will be present on our site.

But we know that the necessary jQuery library is already present, so what's the point of loading it more than once?

This chapter is about those small things that visitors don't see, but that are necessary to make a well-developed site. Just follow along with me in this chapter. We are going to see:

  • How to remove unnecessary jQuery loads
  • What happens with jQuery UI
  • Tips and tricks
  • Some warnings

Note

Though you can pass over this chapter, and go directly to Chapter 6, Getting Our Hands on Coding JavaScript, I really encourage you to continue and learn the inner workings of our site. This knowledge will surely help you when developing any site.

Warning

In this chapter, we are going to do lots of modifications to our site, but some things have to be taken into account before making these changes.

The first thing that you should always do before making any changes is take a backup of your site. You can do this manually or by using an extension like Akeeba backup, which can be found in the JED or at the following link:

http://extensions.joomla.org/extensions/access-a-security/backup/1606

Having a backup copy is essential to restore a working copy of our site if a mistake is made.

Also, you may be wondering whether, later, if you install a newer version of the extension, you may lose all of the changes made. This can happen; therefore, we have made these modifications after we have finished installing the extensions we need.

But don't worry too much about that. You won't be installing a newer version of an extension every day. Mostly, you will install a newer version of the extension if bugs have been found or if the version introduces some features you want.

Otherwise, if the site is working nicely and there are no bugs or newer features, we don't need to update these extensions.

Anyway, the most important thing to remember is to backup. Always keep a backup of your work.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.97.216