Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Commit

Permalink
Update example for GOVUK modules to be consistent with current codebase
Browse files Browse the repository at this point in the history
Updated to reflect @colinrotherham 's changes to enable support for module loaders.
alphagov/govuk_frontend_toolkit#290
(Hopefully in the future we can remove this boilerplate in favour of a proper module system 🙌 )
  • Loading branch information
NickColley committed Jul 5, 2016
1 parent 80af344 commit 1d66fbf
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions js.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,20 @@ Modules should be wrapped in a closure and attach themselves to the global
`GOVUK` object.

```
(function() {
(function(global) {
"use strict";
window.GOVUK = window.GOVUK || {};
var $ = window.jQuery;
var $ = global.jQuery;
var GOVUK = global.GOVUK || {};
...
GOVUK.myModule = ...
}());
...
global.GOVUK = GOVUK;
})(window);
```

**Why:** attaching to the `GOVUK` object keeps us from polluting the global
Expand Down

0 comments on commit 1d66fbf

Please sign in to comment.