开发者

static html or site through javascript

开发者 https://www.devze.com 2023-03-22 14:35 出处:网络
im creating a site and my entire site is in javascript, but i was 开发者_JAVA百科thinking do i need to have the site in html too and do i really need to have html for mobile version too?

im creating a site and my entire site is in javascript, but i was 开发者_JAVA百科thinking do i need to have the site in html too and do i really need to have html for mobile version too?

desktop browser:

  • html only version
  • javascript version

mobile browser:

  • html only version
  • javascript version

do i really need to have html only version for people who dont have javascript and how much important it is to have html only version too?


A lot of this depends upon who your target audience which isn't something you've told us anything about. It's certainly reasonable these days for many sites to only target viewers who have Javascript capabilities.

But, assuming you want the search engines to index your site, you will have to offer something to them that meets their cloaking guidelines, yet shows content to them without javascript. If you aren't aware of cloaking, it's when a site shows one set of content to regular viewers and a different set of content to a search engine usually done in the interest of improving search results by deceiving the search engine about what content is really shown to viewers. You do not have to show exactly the same presentation to views and search engines, but you do need to show the same content.

As for a mobile-specific site, that is again up to you depending upon your target. You could turn the knob in a number of different places. On one end of the spectrum is just making sure that your regular site works in the popular smartphone browsers (Android, iPhone, Blackberry, Windows Phone, etc...). On the other end of the spectrum is a specific and different site design that is served up for mobile. In the middle is a small-screen aware design that adapts itself to smaller displays.


You need HTML to build a website. What you see when you visit a website is the HTML code that browser interprets and renders. Javascript is a scripting language that runs in addition to.

Are you trying to determine if you should handle the case when Javascript is turned off? If so, check out this stats: http://www.w3schools.com/browsers/browsers_stats.asp It's not comprehensive, but the point is the percentage of users who don't have JS turned on is minuscule, so you should weigh the benefit over your development cost.

You shouldn't render the entire content of your website using JS though. Search engine crawlers can't see what the JS outputs. They can only see what the server returns.


You could leave the javascript part as an external .js file, containing the parts that you most probably won't need to change or update any time soon. The main site would then be html, containing header with a link to a css file, your javascript file etc, as in:

 <head>
    <link href="/site_media/styles.css" media="screen" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript" src="/site_media/js/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="/site_media/js/htmlinserts.js"></script>    
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"/> 
    <link rel="SHORTCUT ICON" href="/site_media/img/logo.ico"/>
</head> 

also add meta tags containing keywords that you want search enginges to find.

Parts that you frequently expect to change, you put in the body part ( <html><body>...</body></html>)

This way, each time a visitor requests your site from a server after you changed the html contents, the server only needs to serve the html, since the javascript and css are most probably still stored in the cash of the visitor's browser.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号