SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question JS phrases inline <head> .. can I hide text from Search Engines?

    For example,

    Most of my javascript functions use a phrase['some_phrase'] call instead of hard coded text. Before these functions are loaded I load a phrase list above every other JS file.

    Code:
    <!-- client script -->
    <script language="javascript" type="text/javascript">
    <!--
    var phrase = Array();
    phrase['_your_description_or_message_should_not_be_empty'] = 'Your description or message should not be empty.';
    etc
    etc
    etc
    My question is ... by adding <!-- xxx //--> does those comments actually "hide" the text that google will find and index? the problem I'm having (maybe not a problem) is I want to hide these phrases and text so search engines do not index it...

    So I need to know if by adding <!-- xxx //--> hides the js content from search engines?

    If not... what is the normal method other than loading a new .js file external?

    Thanks

  2. #2
    SitePoint Zealot rhlowe's Avatar
    Join Date
    Sep 2006
    Location
    San Diego
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe that
    HTML Code:
    <!-- foo //-->
    only hides the code from older browsers, like old Netscape.

    Secondly, to include an external JavaScript file, put the following in the document head
    HTML Code:
    <script type="text/javascript" src="/path/to/file.js"></script>
    San Diego Freelance Web Development Contractor
    Great Taste, no Filler. Now with no Trans Fat!

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Specifically, it was to hide the script from browsers that didn't understand scripting. That is, the original netscape 1 and Mosaic.

    The comment hack is archaic and of next to no use now. However, if you really care about how a Netscape 1 user will experience your page, feel free to go ahead.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Guru Ruben K.'s Avatar
    Join Date
    Jun 2005
    Location
    Alkmaar, The Netherlands
    Posts
    693
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does google even parse javascript?

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    I wouldn't think so
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #6
    SitePoint Zealot rhlowe's Avatar
    Join Date
    Sep 2006
    Location
    San Diego
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ruben K. View Post
    Does google even parse javascript?
    It is generally assumed and accepted that Google ignores JavaScript, but no one knows for sure.
    San Diego Freelance Web Development Contractor
    Great Taste, no Filler. Now with no Trans Fat!

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,809
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    If you move it into its own separate file then search engines will most likely ignore it. While it is in the HTML the search engines have to read past it to get to your real content.

    <!-- --> hides the content of the script from Mozaic, Netscape 1, Internet Explorer 1 & 2, any browser that receives the page as XHTML and most content management systems.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  8. #8
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Thanks guys,

    The initial solution was using the loading of the phrases via external <script src=""> call but because many users use languages other than english, I found that when parsing the phrases, then writing them to the actual javascript file (does this every 20 minutes as a cache feature)... sometimes encodings are wrong and I now wanted to move all phrases back from the external file ... inline the page where I know that the phrases will use the same encoding defaults as the other text in the template/document.

    My only concern is after months of adding new phrases for the javascript functions built, the phrases must be loaded in the <head> also. The phrase[xxx] array I built actually holds the phrases for the other javascript functions written so the phrases must be spit out before the other functions load.

    While this is okay with me the post here is basically to ask and confirm with gurus if it's safe to leave these many phrases in the <head> based on SEO purposes. It's quite the opposite I'm trying to achieve here... I'm not trying to put these phrases here to increase the site's phrases/text/content... I'm doing this so the application being discussed can actually work using this method without having the burden of worrying about rankings/search engine bots.

    I don't want search bots to read the phrases... so I was looking for a feature or browser function that would disable search engines from reading those phrases (or skipping them) without affecting a customer's web site using this application (based on contextual adverts and such).

    As far as I'm aware, the only explaination I've heard from this thread is that search engines will not read <script>xxx</script>.. if that's true I'm all set.. if that's a myth can we quickly expose that so I can hear other examples.

    Here's what the page looks like so far:

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html dir="ltr" lang="us">
    <head>
    <title>Main Menu</title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <base href="http://192.168.2.100/">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta name="description" content="xxx">
    <meta name="keywords" content="xxx">
    <meta name="generator" content="xxx">
    <meta name="robot" content="index, follow" />
    <meta name="revisit-after" content="1">
    
    <!-- client script -->
    <script language="javascript" type="text/javascript">
    <!--
    var phrase = Array();
    phrase['_your_description_or_message_should_not_be_empty'] = 'Your description or message should not be empty.';
    phrase['_confirmation_please_make_sure_you_enter_the_members_correct_userid'] = 'Confirmation - Please make sure you enter the members correct UserID. This member will be notified via email, and will be given two links as choices to accept or deny RFP(s) takeover. Are you sure?';
    phrase['_please_read_accept_terms_to_submit_form'] = 'Please read/accept terms to submit form';
    phrase['_you_did_not_select_a_subscription_plan_above'] = 'You did not select a subscription plan above.';
    phrase['_you_did_not_select_a_subscription_plan_to_upgrade'] = 'You did not select a subscription plan to upgrade.';
    phrase['_please_fix_the_fields_marked_with_a_warning_icon_and_retry_your_action'] = 'Please fix the fields marked with a warning icon and retry your action.';
    phrase['_invalid_currency_characters_only_numbers_and_a_period_are_allowed_in_this_field'] = 'Invalid Currency Character(s) Only numbers (0-9) and a period are allowed in this field.';
    .....
    .....
    //-->
    </script>
    <script language="javascript" type="text/javascript" src="http://192.168.2.100/functions/javascript/functions.js"></script>
    Thanks again!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •