mirror of
https://github.com/less/less.js.git
synced 2026-01-24 22:58:04 -05:00
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:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user