• This repository has been archived on 18/Oct/2021
  • Stars
    star
    847
  • Rank 53,812 (Top 2 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 13 years ago
  • Updated about 12 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Detector is a simple, PHP- and JavaScript-based browser- and feature-detection library that can adapt to new devices & browsers on its own without the need to pull from a central database of browser information.

Detector v0.8.5

Detector is a simple, PHP- and JavaScript-based browser- and feature-detection library that can adapt to new devices & browsers on its own without the need to pull from a central database of browser information.

Detector dynamically creates profiles using a browser's (mainly) unique user-agent string as a key. Using Modernizr it records the HTML5 & CSS3 features a requesting browser may or may not support. ua-parser-php is used to collect and record any useful information (like OS or device name) the user-agent string may contain.

With Detector a developer can serve the appropriate markup, stylesheets, and JavaScript to a requesting browser without being completely dependent on a front-end-only resource loader nor a browser-detection library being up-to-date.

The server-side portion of Detector is based upon modernizr-server by James Pearce (@jamespearce) and the browser-detection library ua-parser-php. Detector utilizes Modernizr for its client-side, feature-detection support.

Demo of Detector

A very simple demo of Detector is available for testing. It's also now in production on the West Virginia University home page.

Features

The following features are as of v0.8.5 of Detector:

  • stores features detected with Modernizr 2.5.2 (list) and browser & device information detected with ua-parser-php (based on ua-parser) on the server as part of a browser profile for easy retrieval
  • uses the user agent string as a unique key for looking up information (e.g. one profile per user agent)
  • majority of tests are run only once per unique user agent string so only one user is ever tested & redirected
  • add your own feature tests and store the results using Modernizr's addTest() API
  • tests can be created that run once per user agent, once per session, or on every request
  • version your browser profiles so you can force them to be recreated after adding new tests
  • easily organize browsers into families based on a mix of supported features & device information
  • browser & bots that don't use JavaScript or cookies can still use your site using a default browser profile
  • provide default families for search engines and browsers that don't support javascript or cookies so your best side is always showing
  • give your mobile users a "desktop" view via family switching (assuming you use a templating system)
  • push feature information to the browser via CSS classes and/or a JavaScript object a la Modernizr
  • use with a templating system like Mustache to create a RESS system

Tutorials

More Information

Credits

First and foremost, thanks to James Pearce (@jamespearce) for putting together modernizr-server and giving me a great base to work from. I also took some of the copy from his README and used it in the section, "Adding Detector to Your Application." Also, thanks to the guys behind Modernizr for giving developers a great lib as well as the the ability to expand Modernizr via Modernizr.addTest(). Finally, thanks to Bryan Rieger (@bryanrieger) & Stephanie Rieger (@stephanierieger) of Yiibu and Luke Wroblewski (@lukew) for providing inspiration via Profile and RESS respectively.

More Repositories

1

Throttle

Throttle is a simple node.js app that makes it easier to test how a website performs on poor network connections. For example, testing a responsive website on a poor 3G connection without actually having to have a poor 3G connection. Simply connect your Mac to ethernet, share the network connection via Airport, run Throttle, and any connected device will then be throttled to the the network speed you specified. Throttle was designed to be used in conjunction with a device lab and products like shim or Adobe Shadow where a shared connection is expected.
JavaScript
212
star
2

lazyBlock

Conditionally load content in responsive designs without relying on AJAX. Proof of concept.
JavaScript
87
star
3

MIT-Mobile-Web

The Mobile Web Project was initially developed during the summer of 2009 and is a fork of the original v0.9 release of the MIT Mobile Web project that can still be found on SourceForge. The project was updated in May 2010. It is a product designed to make it easier for higher education institutions to deliver mobile-optimized information and services. It helps deliver task-based content like maps, events, and directory information optimized for device "families." Full documentation can be found at http://mobilewebosp.pbworks.com/ Updates to the project can be found on Twitter at http://twitter.com/mobilewebosp/
PHP
57
star
4

ua-parser-php

ua-parser-php is now distributed via the central ua-parser GitHub repo maintained by Tobie Langel, Lindsey Simon, and myself. See the link below to review the latest code.
PHP
38
star
5

CSS3-Snowflakes

Some simple CSS for creating snowflakes as well as some JavaScript for quickly adding them to your website.
CSS
32
star
6

Google-Maps-v3-for-jQTouch

A simple example showing how someone can get r133 of jQTouch working with Google Maps v3.
19
star
7

css-rule-saver

Compares a list of CSS rules against an HTML file to see which rules apply and should be saved.
CSS
13
star
8

Mobile-Web-iPhone-Wrapper

A very simple iPhone app that uses UIWebView to render a mobile version of a website. NOT production ready and meant simply as an example.
Objective-C
12
star
9

Foursquare-Statistics

This tool should help higher ed institutions gauge interest/usage of foursquare on their campus. Simply provide a text file with a list of venues and the script will tell you total check-ins, top five venues, check-ins per venue, & total mayors.
PHP
6
star
10

popular-queries-for-gsa

Produces a list of popular queries used to search your Google Search Appliance (GSA) that can be included on your search home page.
PHP
4
star
11

dmolsen.com

My website
JavaScript
3
star
12

MQSugr

MQSugr is a wrapper for Modernizr.load that provides some syntactic sugar for loading CSS and JavaScript files using media queries and browser features. MQSugr was developed as a way for me to learn more about JavaScript.
JavaScript
2
star
13

sump-pumper

A small program for the Spark Core that monitors an attached water sensor.
Arduino
1
star
14

responsive-image-tests

Looking at performance of, primarily, front-end responsive image techniques. Focused on when various page loading events fire as well as overall requests/size.
1
star