Optimize Convoluted Code via JavaScript
Search engines loathe crawling through convoluted lines of code. Oceans of complex JavaScript scare away the priceless indexing and archiving efforts of most major search engines, which will generally abort a crawl upon encountering such mess. The good news is that search engines actually do not deploy JavaScript, so it is possible to use JavaScript to hide those miles of messy code by using the fundamental document.write function.
Place this function in an external JavaScript file, “navmenu.js”:
function navMenu() {
document.open();
document.write("<div>Convoluted code goes here.</div>");
document.close();
}
Link to the external JavaScript file by placing this code in the document head:
<script src="js/navmenu.js" type="text/javascript"></script>
Finally, call the function by adding this to the target location within the document body:
<script type="text/javascript">
<!--//--><![CDATA[//><!--
navMenu();
//--><!]]>
</script>
Related articles
- One Link to Open Them All
- Auto-Focus Form Elements with JavaScript
- Prevent JavaScript Elements from Breaking Page Layout when Following Yahoo Performance Tip #6: Place Scripts at the Bottom
- Maximum and Minimum Height and Width in Internet Explorer
- Embed Flash and Video via the object Tag
- The Friendliest Link Targets in the Neighborhood
- Unicode Character Reference for Bloggers
About this article
This is article #194, posted by Perishable on Tuesday, August 29, 2006 @ 10:21am. Categorized as Function, Optimization, and tagged with code, html, javascript, optimize, xhtml. Updated on November 04, 2007. Visited 14745 times. 0 Responses »
Bookmark • Subscribe • Explore
« HTML Frames Notes Plus • Up • Auto Clear and Restore Form Elements »