I was just wondering I know that search engine cannot read javascript and having it on ones pages ruins the pages code to text ratio. I use PHP includes for all my javascript files and was wondering if there is a way to make it so that the javascript shows up on my pages for my visitors but is not visible to search engines.
will that hide all the code from search engines and would that look something like this. Sorry not much of a programmer. <? include("javascript.js"); ?>
PHP is not needed for this. Move your js code to the dedicated file and include it in HTML like this: <script type="text/javascript" src="jscode.js"></script> HTML:
ok but the reason i was asking is because the same script will be used in 3 or 4 different places on the same page so i guess i need to know what is the code to use for the actual placement of the javascript so it appears where i want it to on the page.
this thread is related to SEO not PHP that is just the language I was using at the time could a Mod change it back
To answer your question, JS script only loads on the client side (external file inclusion) and it will not be visible to the bots
yes but it appears in the sites code which means it can be viewed by bots. an i know google can see it cause according to google sitesmaps they tried to spider and external link from one of the kanoodle ads which in return generated a 404 error.
google doesn't pull images or external stylesheets or javascript. So unless your external javascript file was linked to directly with href links, it won't be spidered.
If you are afraid of code, used in different places, make JS function, but you must include external JS file, not embed it to your HTML
Not affraid of code just wanting to try it for something different as an experiment with the sites rankings.
You know, I do not think that Kava Script will really affect you site rank, at least if it will, then it will be the last criteria
JavaScript in the file shouldn't effect page rank or readability by the search engine (especially Google). Getting query strings out of URLs and building content is what's really important. Also getting links on higher PR sites than you, increases your PR (so I've heard). Cheers,
If I understand your request, you want to display javascript *only* if it's a normal user and *not* if it's a search engine bot. If that understanding is correct, you can add the following function to your PHP functions: <? function check_search_engine() { if (!isset($_SERVER['HTTP_USER_AGENT'])) { $user_agent = ''; } else { $user_agent = $_SERVER['HTTP_USER_AGENT']; } $search_engines[] = 'Fast'; $search_engines[] = 'Slurp'; $search_engines[] = 'Ink'; $search_engines[] = 'Atomz'; $search_engines[] = 'Scooter'; $search_engines[] = 'Crawler'; $search_engines[] = 'bot'; $search_engines[] = 'Genius'; $search_engines[] = 'AbachoBOT'; $search_engines[] = 'AESOP_com_SpiderMan'; $search_engines[] = 'ia_archiver'; $search_engines[] = 'Googlebot'; $search_engines[] = 'UltraSeek'; $search_engines[] = 'Google'; foreach ($search_engines as $key => $value) { if ($user_agent != '') { if(strstr($user_agent, $value)) { $is_search_engine = 1; } } } if (isset($is_search_engine)) { return TRUE; } else { return FALSE; } } ?> Code (markup): So that it's always accessible to your php pages, then wherever you want to conditionally insert your javascript code (for users only and not search engines), you could use something like: <? if (!check_search_engine()) { <? include("javascript.js"); ?> } ?> Code (markup): Hope that helps.
It is called cloaking. I would not recommend to provide different content for users and SEs, by doing this you could be penalized.