You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the docs, calling less.render() with a callback allows synchronous processing of the resulting CSS code:
If you specify a callback then a promise will not be returned, where as if you do not specify a callback a promise will be given. Under the hood, the callback version is used so that less can be used synchronously.
This works in both environments, NodeJS and browser, until I use an @import statement and the browser starts to behave asynchronously. (NodeJS still renders synchronously using the syncImport option.)
sync imports used to be used in Less in the browser, but browsers are phasing out the ability to do XHR sync requests at all, because it kills your webpage.
It's not so much an "@import forces asynchronous behaviour" as much as async is all that is available in the browser. But yes, that should be called out as a Node-only feature. Sorry it was confusing for you!
(Copied from less/less.js#3238)
According to the docs, calling
less.render()
with a callback allows synchronous processing of the resulting CSS code:This works in both environments, NodeJS and browser, until I use an
@import
statement and the browser starts to behave asynchronously. (NodeJS still renders synchronously using thesyncImport
option.)@matthew-dean explains that this is by design:
I suggest this should be mentioned either in the paragraph about synchronous processing and/or in the section about @import At-Rules.
The text was updated successfully, but these errors were encountered: