Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Externalizing the Code

When you’re working with CSS and JavaScript, it’s important to externalize the code. Externalizing the code is basically putting all your definitions in a file, putting that file on your site, and using a single line of code within your actual pages to tell the browser (and search engines) where to find it. Because the code represents the building blocks of your web site, there’s going to be a lot of it. Just the JavaScript for your analytics alone can take up dozens of lines of code, maybe even hundreds. Externalizing your code is streamlining your page-designing process.

Not only does it reduce the size of your page to externalize CSS and JavaScript, giving your browser less to load, but if you want to go in and change all of your headings to blue, all you need to do is go to the glossary page where all the terms are defined and change that particular code to blue; the change then appears throughout your web site. You don’t have to go through every single page and do it by hand. The advantage for SEO is that externalizing your code makes the page code much cleaner, thus making the content-to-code ratio much higher overall.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint