Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reload CSS when using Less.js

I can see in the source that it basically reloads css automatically if you are on localhost, and I can see in the firebug panel that it's requesting the .less file(s) every second.. but when I change something in the files it's not updated on the page unless I do a full refresh.

I also tried using less.refresh() as described here:

https://github.com/cloudhead/less.js/issues/346

But to no avail.

So, how can I reload the .less files without reloading the page?

Thanks

like image 550
Naatan Avatar asked Oct 13 '11 16:10

Naatan


People also ask

How do I force a CSS file to reload?

All you have to do is to perform a hard or force-reload or empty the local cache if necessary. If you're using Chrome, you can force reload by pressing the F12 key to open the console. Then, right-click the reload button to access the menu containing the options for reloading.

How do I force the browser to reload cached .JS CSS?

It works, all the time, for everyone. But, if you're not using it, and you just need to reload that one CSS or JS file occasionally in your own browser... just open it in its own tab and hit SHIFT-reload (or CTRL-F5)!

How do I change the content of a page without reloading it?

AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page. Classic web pages, (which do not use AJAX) must reload the entire page if the content should change.

How do you force reload in JS?

You can use the location. reload() JavaScript method to reload the current URL. This method functions similarly to the browser's Refresh button. The reload() method is the main method responsible for page reloading.


1 Answers

Found the answer to my question here:

https://github.com/cloudhead/less.js/issues/168

Basically had to add a header to prevent caching .less files.

like image 167
Naatan Avatar answered Oct 21 '22 13:10

Naatan