Skip to content

Commit e6b9f50

Browse files
committed
Improving documentation for loading jQuery. Now using Google CDN with fallback to local jQuery.
1 parent 65f9bc7 commit e6b9f50

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/patterns/jquery.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Loading jQuery
2323
In order to use jQuery, you have to download it first and place it in the
2424
static folder of your application and then ensure it's loaded. Ideally
2525
you have a layout template that is used for all pages where you just have
26-
to add a script statement to your `head` to load jQuery:
26+
to add a script statement to the bottom of your `<body>` to load jQuery:
2727

2828
.. sourcecode:: html
2929

@@ -35,15 +35,15 @@ Another method is using Google's `AJAX Libraries API
3535

3636
.. sourcecode:: html
3737

38-
<script type=text/javascript
39-
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
38+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js"></script>
39+
<script>window.jQuery || document.write('<script src="{{
40+
url_for('static', filename='jquery.js') }}">\x3C/script>')</script>
4041

41-
In this case you don't have to put jQuery into your static folder, it will
42-
instead be loaded from Google directly. This has the advantage that your
42+
In this case you have to put jQuery into your static folder as a fallback, but it will
43+
first try to load it directly from Google. This has the advantage that your
4344
website will probably load faster for users if they went to at least one
4445
other website before using the same jQuery version from Google because it
45-
will already be in the browser cache. Downside is that if you don't have
46-
network connectivity during development jQuery will not load.
46+
will already be in the browser cache.
4747

4848
Where is My Site?
4949
-----------------

0 commit comments

Comments
 (0)