I have this code on my header (I know sort of bad practice):
?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/cleditor/jquery.cleditor.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.expander.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.qtip-1.0.0-rc3.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/custom.js"></script>
</head>
I don’t want to include this one:
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/cleditor/jquery.cleditor.min.js"></script>
on mobile and tablet. Any ideas of how to accomplish this?
As far as I know, there are no 100% safe solution to detect mobile devices :
UA sniffing depends on a list of mobile UA. Those lists are quite up to date, but can’t handle the future/rare devices.
feature detection is quite hard when the criteria is as broad as “mobile/tablet”. Screen resolution is not anymore so different between non mobile and mobile (check the new Google Phone, better res than a netbook), touch support can be found in classic lcd screens…
I would go for a php UA sniffing solution based on WURFL, without redirect : if not mobile, echo your script, if mobile, echo a nothing.
But the mobile and non mobile world are merging. You should use feature detection to check for the support of specifics features you want to use, whether it’s a mobile or a non mobile device.
Check http://detectmobilebrowsers.mobi/ for a simple UA sniffing in php