Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: bbcBrew
Fetching contributors…

Cannot retrieve contributors at this time

executable file 82 lines (63 sloc) 2.515 kB
BBC Brew 1.0.0 alpha 1
======================
This is the first release of BBC Brew. It is intended for testing and
shouldn't be used in a live environment.
Using BBC Brew
==============
The Brew Loader is JavaScript loader that provides for asynchronous,
sandboxed loading of the Brew Library, a version of the jQuery
JavaScript Library with bespoke BBC Widget Plugins pre-installed and
configured for use on BBC web sites.
There are 2 options for including the Brew Library onto your page.
Asynchronous loading (recommended)
----------------------------------
This makes Brew load in the background, which doesn't block page
rendering.
<!-- Include the loader, this is best at the end of your page -->
<script type="text/javascript" src="/scripts/brew/1.0.0/brew.js"></script>
<script type="text/javascript">
Brew(1).ready(function($) {
// the jQuery object has loaded and the DOM is ready
$('body').append('brew is ready!');
});
</script>
Using this pattern the $ name will not affect the global scope, it
only exists inside your ready callback. Although this isn't best in terms
of bandwidth, it does allow multiple versions of jQuery can be loaded
safely onto the same page at the same time.
For larger apps, this pattern may be more useful
<script type="text/javascript">
(function() {
var $ = Brew(1).ready(init);
function init() {
// use $ in your application here
}
})();
</script>
To add Brew Library plugins to jQuery, you simply list which specific
packages you wish to have loaded. These will load asynchrounously as well
and Brew will track all the required downloads and dependencies for you.
<script type="text/javascript">
Brew(1).load('ui').ready(function($) {
// $ has loaded and the DOM is ready
$('body').append('jQuery & Brew UI plugins are now ready!');
});
</script>
In principle Brew is analagous to the Gloader tool, which was used to
load the BBC Glow library.
The full docs for Brew can be found in brew.debug.js, search for
"@name Brew"
Synchronous loading
-------------------
Using the Brew Loader is optional, you can load Brew synchronously into
the global scope via:
<!-- it is best to include this at the end of your page -->
<script type="text/javascript" src="/scripts/brew/1.0.0/core.js"></script>
<script type="text/javascript" src="/scripts/brew/1.0.0/ui.js"></script>
<script type="text/javascript">
var $ = window.jQuery; // optional
$(function() {
// now the dom is ready
$('body').append('brew is ready!')
});
</script>
Jump to Line
Something went wrong with that request. Please try again.