-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
less.render() in browser becomes async with @import #3238
Comments
Nothing. The documentation should probably be updated to reflect that. |
What @rjgotten said. 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. EVERYTHING stops processing / evaluating until the file is returned. When your files are all local (on Node), it's less of a problem. |
Closing as designed. Please open a ticket at https://github.com/less/less-docs re: the documentation. |
Thanks for the quick replies. I get the reasoning but would argue that still a switch to force sync behaviour would be nice. In my case it would only apply during development, anyway. However, as you mention even browser makers are phasing out the sync option I feel there is not much to argue about, anymore… 😺 |
@p3k Even if Less allowed it, the browsers will not at some point, so it effectively wouldn't matter. See: https://developers.google.com/web/updates/2012/01/Getting-Rid-of-Synchronous-XHRs |
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.)In the example code above,
css1
will showundefined
whilecss2
shows the expected CSS codebody { background-color: yellow; }
.I created a Thimble to demonstrate the issue: https://thimbleprojects.org/p3k/509773/
What am I missing here?
The text was updated successfully, but these errors were encountered: