Skip to content

Commit

Permalink
Allow isMobile to exist in global space in AMD environment
Browse files Browse the repository at this point in the history
  • Loading branch information
spotify-kai committed Nov 20, 2014
1 parent 3be399d commit fc39bd3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ I couldn't do detection on the back-end, because the entire site was cached and

So I resorted to UA sniffing.

I tried to keep the script small (**currently ~740 bytes, minified**) and simple, because it would need to execute in the `<head>`, which is generally a bad idea, since JS blocks downloading and rendering of anything else while it parses and executes. In the case of mobile redirection, I don't mind so much, because I want to start the redirect as soon as possible, before the device has a chance to start downloading and rendering stuff. For non-mobile platforms, the script should execute fast, so the browser can quickly get back to downloading and rendering.
I tried to keep the script small (**currently ~1.3k bytes, minified**) and simple, because it would need to execute in the `<head>`, which is generally a bad idea, since JS blocks downloading and rendering of anything else while it parses and executes. In the case of mobile redirection, I don't mind so much, because I want to start the redirect as soon as possible, before the device has a chance to start downloading and rendering stuff. For non-mobile platforms, the script should execute fast, so the browser can quickly get back to downloading and rendering.

## How it works

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isMobile",
"version": "0.3.4",
"version": "0.3.5",
"main": "isMobile.js",
"ignore": [
"**/.*",
Expand Down
4 changes: 2 additions & 2 deletions isMobile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* isMobile.js v0.3.4
* isMobile.js v0.3.5
*
* A simple library to detect Apple phones and tablets,
* Android phones and tablets, other mobile devices (like blackberry, mini-opera and windows phone),
Expand Down Expand Up @@ -103,7 +103,7 @@
module.exports = instantiate();
} else if (typeof define === 'function' && define.amd) {
//AMD
define(instantiate());
define(global.isMobile = instantiate());
} else {
global.isMobile = instantiate();
}
Expand Down
2 changes: 1 addition & 1 deletion isMobile.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ismobilejs",
"version": "0.3.4",
"version": "0.3.5",
"description": "A simple JS library that detects mobile devices.",
"keywords": [
"ismobile",
Expand Down

0 comments on commit fc39bd3

Please sign in to comment.