• Resolved photocurio

    (@photocurio)


    I’m trying to make my themes reasonably responsive without creating dedicated mobile themes. I’ve simply been putting @media CSS at the bottom of my stylesheets. I’m not sure what to do about the javascript though. One javascript (Masonry) messes up the rendering of the site on a phone, and its unnecessary bandwidth.

    My javascripts are loaded in my functions file, using the enqueue script function.

    Can I incorporate an @media conditional into enqueue script? Or is there a better way to do it?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Feel free to snoop around my https://www.ads-software.com/extend/themes/responsive I don’t believe that this is needed. All media queries are in a single style.css and IE via respond.js pretty straight-forward solution ??

    Emil

    Use the PHP Mobile Detect Class and then enqueue which scripts you want depending on the device.

    Thread Starter photocurio

    (@photocurio)

    Andrew, that works, sort of.
    But the code to query to see it its a mobile device is

    if ($detect->isMobile()) {
        // any mobile platform
    }

    What I need is “if its NOT mobile”. The obvious if($detect->!isMobile() {} does not work.

    Thread Starter photocurio

    (@photocurio)

    I think I found it:
    ($detect->isMobile() ==false )
    that’s the power of trial and error. O and thanks for the tip!

    I forget not everyone writes php everyday sometimes!

    I’m glad you figured it out. That’s really the most rewarding and productive way of approaching programming problems in general.

    $detect->!isMobile() isn’t going to work ever, it’s not proper php syntax. You don’t run the true/false statement on the function call itself. What I think you were trying to do is if(!$detect->isMobile()). What that is essentially saying is: if the result of running isMobile() in the instantiation of $detect is false, or zero, or null, do this. In other programming languages you’ll have to be more specific but php will figure it out for you, in this case anyway.

    Your example, if($detect->isMobile() == false) is functionally equivalent to a properly formatted if(!whatever) in php. Hope that helps your future programming in the language.

    Happy coding!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘I need to deregister some scripts for mobile devices’ is closed to new replies.