diff --git a/lib/less-browser/bootstrap.js b/lib/less-browser/bootstrap.js
index 706f98bf..30193b5c 100644
--- a/lib/less-browser/bootstrap.js
+++ b/lib/less-browser/bootstrap.js
@@ -13,14 +13,13 @@ require("./add-default-options")(window, options);
var less = module.exports = require("./index")(window, options);
+window.less = less;
+
if (options.onReady) {
if (/!watch/.test(window.location.hash)) {
less.watch();
}
- less.pageLoadFinished = less.registerStylesheets().then(
- function () {
- return less.refresh(less.env === 'development');
- }
- );
-}
\ No newline at end of file
+ less.registerStylesheetsImmediately();
+ less.pageLoadFinished = less.refresh(less.env === 'development');
+}
diff --git a/lib/less-browser/index.js b/lib/less-browser/index.js
index c6dc4502..376bba54 100644
--- a/lib/less-browser/index.js
+++ b/lib/less-browser/index.js
@@ -187,20 +187,28 @@ module.exports = function(window, options) {
less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; };
//
- // Get all tags with the 'rel' attribute set to "stylesheet/less"
+ // Synchronously get all tags with the 'rel' attribute set to
+ // "stylesheet/less".
+ //
+ less.registerStylesheetsImmediately = function() {
+ var links = document.getElementsByTagName('link');
+ less.sheets = [];
+
+ for (var i = 0; i < links.length; i++) {
+ if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
+ (links[i].type.match(typePattern)))) {
+ less.sheets.push(links[i]);
+ }
+ }
+ };
+
+ //
+ // Asynchronously get all tags with the 'rel' attribute set to
+ // "stylesheet/less", returning a Promise.
//
less.registerStylesheets = function() {
return new Promise(function(resolve, reject) {
- var links = document.getElementsByTagName('link');
- less.sheets = [];
-
- for (var i = 0; i < links.length; i++) {
- if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
- (links[i].type.match(typePattern)))) {
- less.sheets.push(links[i]);
- }
- }
-
+ less.registerStylesheetsImmediately();
resolve();
});
};