-
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
Callback when client side less screen is ready #1666
Comments
okay,
https://github.com/less/less.js/blob/master/lib/less/browser.js#L673 such that once all requests have come back, it calls less.stylesLoadedCallback if that exists. |
I would like to have a callback also so I know when to run a css prefixer library like https://github.com/codler/jQuery-Css3-Finalize |
aha nice, thanks! How do I use it? Is it |
By the code it looks like the function should accept CSS styles and return processed styles as a string. |
Here is the code I use
|
This is fixed in PR #2226. Current state of the PR allows you to recognize when less has finished processing via a promise: less.hasFinished.then(
function() {
// code to run after less has finished
}
) This also works with |
I managed to achieve this in my dev env with Less 2.5.3: <style type="text/css" id="prevent-fouc">
body {
display: none !important;
}
</style>
<script type="text/javascript">
less = {
env: "development",
async: true
}
</script>
<!-- include styles and less -->
<script type="text/javascript">
less.pageLoadFinished.then(function() {
$('#prevent-fouc').remove();
});
</script> Disclaimer: I support not making the user's browser compile the whole Bootstrap or any other CSS framework, it's a horrible idea: just think mobile phones have limited capacity. |
Closing as added in |
Using client side less, it takes several seconds to render a twitter bootstrap screen.
While less is creating the css, the browser shows unstyled html.
(I use client side less so users can change less options at runtime.)
Is there a js callback or other feature which will let me hide the screen and unhide it when less has finished creating the css (equivalent of document.ready).
If not, can the facility be added?
The text was updated successfully, but these errors were encountered: