-
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
How to tell when less is done processing ? #283
Comments
Sounds like a good idea. |
Good idea ! |
Upvoted! |
This is really, really, really BADLY needed in order to be able to avoid FOUC! |
it is not recommended to run less.js in the browser in production. for development set a timeout for x milliseconds.. wouldnt that be good enough? |
Why not, and what is recommended instead if one does rely on Szczepan Hołyszewski |
Its not recommended because its bad for performance and only runs correctly on a small set of (modern) browsers. You are right that there are also several bugs that make it more difficult. Instead, compile the less before hand in node - This support javascript - unless you are accessing variables on the page? In which case it depends on your serverside setup and what variables you use, but it might be better to try and move that serverside. There are cases where it makes sense to use less.js browser side - for instance in a theme editor where a admin user is editing things on the fly.. but then for more generic users it would be better to compile and cache serverside. So it does depend on your situation and I'm not saying this feature request will never get added, just that it is low priority. |
Why not to just add stylesheet node DOM event firing& It is very easy to implement and will not hit the performance. But it wil allow to catch stylesheet refreshing (especially important in watch mode) for any purposes. For example, i'm writing ajax-based Less stylesheets updater, cause im'not able to install Node.js on hosting. |
My use-case IS an theme editor, and so I would find this highly useful! |
@roelvanduijnhoven happy to accept pull requests |
Maybe I will look into this. The way I fix this at the moment is to poll every few miliseconds until a specific css style has been loaded on a DOM element. Although this works in practise this is 1) a nasty hack and 2) can break in theory because not all styles could have been loaded at that moment in time. |
It would be very nice and pretty standard to have a callback function for after LESS is done processing. |
I agree. That is why it is labeled ReadyForImplementation and has a milestone of the next release.. it is just waiting for someone to implement.. |
👍 |
I'd like to jump in on this. Is any one working on this yet? I've browsed the PRs and didn't see it. I also didn't see it on the 2.0.0 release checklist #1902. @lukeapage do you know if there is somewhere I can contribute to this feature or if I need to start it from scratch? Thanks! |
Hi, Good news, thanks. 1. Branch from the v2 branch. 2. Consider we want to How about a promise on the less object which is resolved after the initial Long term (not necessary for your pull request) we can make refresh return Open to discuss alternatives, am sketching this out from a mobile phone... |
Awesome. Being there is room for jumping in I'm gonna branch v2, grokk the issue and your comments better, and come back with some ideas. Looks like there have been a few changes since I last perused the source 1.7.0 ;)
Not sure what is meant by 'thing' here though. |
Sorry I know it wasn't clear - I mean that its easy to keep adding events and options to less - I'd rather refactor what we have to make it able to be used in a more flexible way than to keep adding options. And I'm saying that exposing an extra field (the thing :)) on the less object is necessary for this and not too bad if we consider further improvements. |
Moving conversation on solutions to PR #2226. |
released in v2 beta 2 |
Hi.
I'm working with jQuery and I'm used to running javascript code as soon as the DOM is ready. The funny bit is that my js is performing operations which involve reading some DOM elements' css attributes. However, it turns out the js may or may not run after Less has done his job.
The consequence is that oftentimes, my js will read values before they are set - thus leading to unexpected behaviors.
My question is simple : is there a way (event, flag...anything) to tell when the less processing is complete and execute JS code after ?
The text was updated successfully, but these errors were encountered: