Allow configuration of asynchronous XHR

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.
This commit is contained in:
Will
2012-09-03 09:03:43 -07:00
committed by Luke Page
parent f8bee84fdf
commit 6bdd800bb6

View File

@@ -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');