A month ago, Google delivered their recommendation for mobile best practices as going with responsive web design.
Since then, there were many questions about implementation of the responsive web design. One such question was how to use JavaScript.
Pierre Far from Google posted more details of JavaScript with responsive design on Google+. He said they updated the documentation with a page specifically about JavaScript and responsive web design.
Pierre explained:
There are three main methods for using JavaScript with responsive design:
JavaScript-adaptive: In this configuration, all devices are served the same HTML, CSS, and JavaScript content. When the JavaScript is executed on the device, the rendering or behavior of the site is altered. If a website requires JavaScript, this is Google’s recommended configuration.
Combined detection: In this implementation, the website uses both JavaScript and server-side detection of device capabilities to serve different content to different devices.
Dynamically-served JavaScript: In this configuration, all devices are served the same HTML, but the JavaScript is served from a URL that dynamically serves different JavaScript code depending on the device’s user-agent.
Forum discussion at Google+.