Skip to content

Commit 1648c0d

Browse files
committed
Thanks to jQuery Cookie for the README template
1 parent de6cb25 commit 1648c0d

File tree

1 file changed

+19
-131
lines changed

1 file changed

+19
-131
lines changed

README.md

Lines changed: 19 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
# jquery.getscripts
1+
# jQuery.getScripts
22

3-
A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
4-
5-
**If you're viewing this at https://github.com/carhartl/jquery-cookie, you're reading the documentation for the master branch.
6-
[View documentation for the latest release (1.4.0).](https://github.com/carhartl/jquery-cookie/tree/v1.4.0)**
7-
8-
## Build Status Matrix
9-
10-
[![Selenium Test Status](https://saucelabs.com/browser-matrix/jquery-cookie.svg)](https://saucelabs.com/u/jquery-cookie)
3+
Load one or multiple JavaScript files from the server using a GET HTTP request, then execute them..
114

125
## Installation
136

7+
This package is available through Bower. From the command-line, run:
8+
9+
bower install jquery.getscripts
10+
1411
Include script *after* the jQuery library (unless you are packaging scripts somehow else):
1512

1613
```html
17-
<script src="/path/to/jquery.cookie.js"></script>
14+
<script src="/path/to/jquery.getscripts.js"></script>
1815
```
1916

2017
**Do not include the script directly from GitHub (http://raw.github.com/...).** The file is being served as text/plain and as such being blocked
@@ -24,128 +21,19 @@ The plugin can also be loaded as AMD or CommonJS module.
2421

2522
## Usage
2623

27-
Create session cookie:
28-
29-
```javascript
30-
$.cookie('the_cookie', 'the_value');
31-
```
32-
33-
Create expiring cookie, 7 days from then:
34-
35-
```javascript
36-
$.cookie('the_cookie', 'the_value', { expires: 7 });
37-
```
38-
39-
Create expiring cookie, valid across entire site:
40-
41-
```javascript
42-
$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
43-
```
44-
45-
Read cookie:
46-
47-
```javascript
48-
$.cookie('the_cookie'); // => "the_value"
49-
$.cookie('not_existing'); // => undefined
50-
```
51-
52-
Read all available cookies:
53-
54-
```javascript
55-
$.cookie(); // => { "the_cookie": "the_value", "...remaining": "cookies" }
56-
```
57-
58-
Delete cookie:
59-
60-
```javascript
61-
// Returns true when cookie was found, false when no cookie was found...
62-
$.removeCookie('the_cookie');
63-
64-
// Same path as when the cookie was written...
65-
$.removeCookie('the_cookie', { path: '/' });
66-
```
67-
68-
*Note: when deleting a cookie, you must pass the exact same path, domain and secure options that were used to set the cookie, unless you're relying on the default options that is.*
69-
70-
## Configuration
71-
72-
### raw
73-
74-
By default the cookie value is encoded/decoded when writing/reading, using `encodeURIComponent`/`decodeURIComponent`. Bypass this by setting raw to true:
75-
76-
```javascript
77-
$.cookie.raw = true;
78-
```
79-
80-
### json
81-
82-
Turn on automatic storage of JSON objects passed as the cookie value. Assumes `JSON.stringify` and `JSON.parse`:
83-
84-
```javascript
85-
$.cookie.json = true;
86-
```
87-
88-
## Cookie Options
89-
90-
Cookie attributes can be set globally by setting properties of the `$.cookie.defaults` object or individually for each call to `$.cookie()` by passing a plain object to the options argument. Per-call options override the default options.
91-
92-
### expires
93-
94-
expires: 365
95-
96-
Define lifetime of the cookie. Value can be a `Number` which will be interpreted as days from time of creation or a `Date` object. If omitted, the cookie becomes a session cookie.
97-
98-
### path
99-
100-
path: '/'
101-
102-
Define the path where the cookie is valid. *By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior).* If you want to make it available for instance across the entire domain use `path: '/'`. Default: path of page where the cookie was created.
103-
104-
**Note regarding Internet Explorer:**
105-
106-
> Due to an obscure bug in the underlying WinINET InternetGetCookie implementation, IE’s document.cookie will not return a cookie if it was set with a path attribute containing a filename.
107-
108-
(From [Internet Explorer Cookie Internals (FAQ)](http://blogs.msdn.com/b/ieinternals/archive/2009/08/20/wininet-ie-cookie-internals-faq.aspx))
109-
110-
This means one cannot set a path using `path: window.location.pathname` in case such pathname contains a filename like so: `/check.html` (or at least, such cookie cannot be read correctly).
111-
112-
### domain
113-
114-
domain: 'example.com'
115-
116-
Define the domain where the cookie is valid. Default: domain of page where the cookie was created.
117-
118-
### secure
119-
120-
secure: true
121-
122-
If true, the cookie transmission requires a secure protocol (https). Default: `false`.
123-
124-
## Converters
125-
126-
Provide a conversion function as optional last argument for reading, in order to change the cookie's value
127-
to a different representation on the fly.
128-
129-
Example for parsing a value into a number:
130-
131-
```javascript
132-
$.cookie('foo', '42');
133-
$.cookie('foo', Number); // => 42
134-
```
135-
136-
Dealing with cookies that have been encoded using `escape` (3rd party cookies):
137-
138-
```javascript
139-
$.cookie.raw = true;
140-
$.cookie('foo', unescape);
24+
```html
25+
<script>
26+
$.getScripts({
27+
urls: ['/path/to/one.js', 'path/to/two.js'],
28+
cache: true, // Default
29+
async: false, // Default
30+
success: function(response) {
31+
// Files have loaded
32+
}
33+
});
34+
</script>
14135
```
14236

143-
You can pass an arbitrary conversion function.
144-
145-
## Contributing
146-
147-
Check out the [Contributing Guidelines](CONTRIBUTING.md)
148-
14937
## Authors
15038

151-
[Klaus Hartl](https://github.com/carhartl)
39+
[David Hudson](https://github.com/hudsonfoo)

0 commit comments

Comments
 (0)