Minimizing JavaScript

By Jacqueline Sinex, Wednesday, August 25, 2010
Javascript Image
Photo by Juanjo Jaramillo on Unsplash

Sometimes a little bit of JavaScript is necessary to control certain features in a website, such as a simple slideshow element on a page, which was a better choice over the heavy Flash animation.  But as organic SEO becomes more prominent, we must learn to minimize the presence of javascript among our web page code, and strive for “clean” search-engine-friendly code.

Instead of including your JavaScript directly on the web page, link to it as a source.

At the head of the page, create the script tag, but instead of including the script code within the container of the script tags, link to an external JavaScript file.  For best organization, store your JavaScript file in a /js folder (or /scripts or something similar).  Your linked tag will appear in this format:

<script language=”javascript” src=”js/filename.js” /></script>

Now, as your page code is read, this is referenced on one line and the search engines (or other resources) do not need to wade through a long Javascript to get to the important meat of your website – the content.

Posted in: Austin Web Design, How To, Quick Tips, Tech Support, Web Development, Web Site Maintenance, WWW Learning Center

Comments are closed.