LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-12-2009, 04:42 PM   #1
entz
Member
 
Registered: Mar 2007
Location: Milky Way , Planet Earth!
Distribution: Opensuse
Posts: 453
Blog Entries: 3

Rep: Reputation: 40
best client side way to include html within html


Hello folks,

what is the best way (i.e standard way that is supported on all browsers and probably as well followed by web crawlers)....

.... to include an html file either locally or externally in another ?

Of course , i've done the research and i also know that there are server side includes (php , asp ...you name it) but that is out of the question!

at the moment , i'm using this:

Quote:
<script type="text/javascript" src="path to file/include-file.js"> </script>
however, i've been warned that this method may not show up in some browsers as some tend to ignore this tag and that crawlers like your favorite search engine wouldn't bother reading this.

so , what is the best and safest way to do the job?

please note that browser compatibility is the highest priority , seo is a distant second concern.

and btw , the reason why i've ousted SSI's from the start is because of among other things:

1) the fact that the included file is static html and because the text is included pretty much everywhere
2) hoping to reduce load time as the code (if successfully recognized) would hopefully be treated like any other embedded external file (e.x like an image) , therefore it would be cached without the need to downloaded it over and over again for each new page on the site.


cheers
 
Old 09-12-2009, 09:56 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Looking at your reasons for trying to deliver the content via the client.
  1. Can you be sure that the file resides on the client? If not then the file will need to be downloaded
  2. How big is the html file you are trying to cache?

My point is that to guarantee that the user gets the data you will need to send it to the client from the server, using something like PHP. You approach of embedding the html in a javascript file will work if javascript is enabled on the browser. If it has been turned off (which it maybe for various reasons) or the user has a browser that doesn't support javascript then it will not work, in which case you will need to send the data from the server.

And if the file is small it may not be worth the extra overhead.

To do this the server will need to identify if the client supports javascript, for example in PHP the get_browser() function will return details about the capabilities of the browser.

Last edited by graemef; 09-12-2009 at 10:14 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML/PHP: Any ideas how to include the RSS feeds into your Webpage? frenchn00b Programming 9 01-19-2013 03:59 PM
PHP include upsets rendering of HTML page. rblampain Programming 6 01-19-2013 04:50 AM
Web: How to send html information back and forth windows... client side only. RHLinuxGUY Programming 3 02-16-2007 07:29 PM
Search & Replace Technique to Fix html HREFs w/o html extension donv2 Linux - Newbie 1 01-30-2007 11:59 PM
Konqueror + file:/usr/share/doc/HTML/index.html jon_k Linux - Software 2 11-25-2003 05:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration