Is the below code problematic in respect to SEO and Google?
This is a small sample of how I intend to change my non-mobile friendly website into mobile friendly using CSS media queries and javascript.
The reason why I want to opt for this type of code is to of course avoid duplicate content in respect to both HTML and code maintenance. The code for the mobile version of the website will be "extracted" from the desktop version, injected in placeholders.
This will allow me to keep the desktop version untouched, add a number of placeholders for the mobile version and populate them in the below way.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style>
@media (max-width: 360px)
{
#ul-desktop
{
display: none;
}
}
</style>
<html>
<ul id="ul-desktop">
<li>Bullet #1</li>
<li>Bullet #2</li>
<li>Bullet #3</li>
<li>Bullet #4</li>
</ul>
<ul id="ul-mobile"></ul>
<script type="text/javascript">
if($(window).width()<=360)
{
$("#ul-desktop li").each
(
function (index)
{
$("#ul-mobile").append("<li>" + $(this).html() + "</li>");
}
);
}
</script>
</html>
Edit
Of course I might as well decide to have two different versions of the page, one for desktop and one for mobile with a big advantage being that mobile users will not have to download my big CSS/JS files used by desktop, they will download a much, much lighter version of my pages.
But I have server restrictions, such as that I cannot implement user-agent redirections on the server side. So I need some help:
Is there any difference between mobile.mydomain.com compared to mydomain.com/mobile, again, in respect to SEO? Due to server restrictions, I'm afraid I can only opt for the latter.
Would a window.location redirection work in my case? I was thinking about using the matchMedia() JavaScript function, hide all content and show a small indicator with "Loading mobile version" and do the redirection. But wouldn't this solution download two versions of the pages, the desktop and the mobile one after the redirection is complete?