From 6bdd800bb68d534b1effefe545b687d12d288e8c Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 3 Sep 2012 09:03:43 -0700 Subject: [PATCH] Allow configuration of asynchronous XHR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set less.async and/or less.fileAsync to true before including less.js to force asynchronous XHR requests to be used.  fileAsync is introduced as a separate setting to maintain existing semantics, as previously changing less.async to true would only affect http protocol XHRs. --- lib/less/browser.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/less/browser.js b/lib/less/browser.js index b7de8be8..f5cf6a55 100644 --- a/lib/less/browser.js +++ b/lib/less/browser.js @@ -17,7 +17,8 @@ less.env = less.env || (location.hostname == '127.0.0.1' || // doesn't start loading before the stylesheets are parsed. // Setting this to `true` can result in flickering. // -less.async = false; +less.async = less.async || false; +less.fileAsync = less.fileAsync || false; // Interval between watch polls less.poll = less.poll || (isFileProtocol ? 1000 : 1500); @@ -229,7 +230,7 @@ function createCSS(styles, sheet, lastModified) { function xhr(url, type, callback, errback) { var xhr = getXMLHttpRequest(); - var async = isFileProtocol ? false : less.async; + var async = isFileProtocol ? less.fileAsync : less.async; if (typeof(xhr.overrideMimeType) === 'function') { xhr.overrideMimeType('text/css');