WordPress.org

Ready to get started?Download WordPress

Forums

Loading Mobile/Desktop Headers Dynamically (2 posts)

  1. CK Hicks
    Member
    Posted 3 years ago #

    Greetings,

    I'm working on a theme framework and need a fresh set of eyes - what are your thoughts on the following process:

    - User agent detected when visitor reaches the site (via: detectmobilebrowser.com)
    - Different header information included with simple PHP (files within template folder)
    - Generic closing </head> tag and life resumes at normal pace!

    So the code looks like this:

    <?PHP detectmobilebrowsermagic ?>
    if mobile useragent: load <html>...</head> for mobile users
    else (desktop useragent): load <html>...</head> for desktop users

    Does this make sense, what are your thoughts on speed vs. functionality, etc. I'd love to hear any thoughts or comments on the process! If you'd seen anything like this I'd really enjoy reading their documentation as well.

    Counterpoint - I read this article about using PHP for browser detection, but the main argument seems to be centered around "you need to keep it updated" which I'm planning on for this framework: http://www.impressivewebs.com/php-browser-detection/ Can anyone think of another reason why I might not want to keep this function within PHP?

    I think this is a fun way to quickly swap between two versions of the head code without a lot of overhead and client-side scripts, which ought to speed up the mobile experience quite nicely.

    Thanks in advance for your thoughts!

  2. CK Hicks
    Member
    Posted 3 years ago #

    Quick note: The idea here is to bypass the need for specific hacks and styles on mobile vs. desktop environments, because the header will only have the necessary scripts for each platform. (I'm using both the mobile/desktop version of HTML5 Boilerplate for testing purposes.) The main idea is only showin the users what they NEED to see, so we can keep it clean and speedy.

Topic Closed

This topic has been closed to new replies.

About this Topic