Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention that @import forces asynchronous behaviour #483

Open
p3k opened this issue Jun 28, 2018 · 1 comment
Open

Mention that @import forces asynchronous behaviour #483

p3k opened this issue Jun 28, 2018 · 1 comment

Comments

@p3k
Copy link

p3k commented Jun 28, 2018

(Copied from less/less.js#3238)

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.)

@matthew-dean explains that this is by design:

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.

I suggest this should be mentioned either in the paragraph about synchronous processing and/or in the section about @import At-Rules.

@matthew-dean
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants