stealjs / steal-less

A less plugin for StealJS
https://www.npmjs.com/package/steal-less
MIT License
4 stars 2 forks source link

Minimize number of HTTP requests made by Less #5

Closed akagomez closed 8 years ago

akagomez commented 9 years ago

I started towards hacking on less.js tonight to see if I could get it to not load duplicates.

In the process I stumbled upon these few lines: https://github.com/less/less.js/blob/master/dist/less.js#L460-L468

Which lead me to this documentation: http://lesscss.org/usage/#using-less-in-the-browser-usefilecache

I set the useFileCache option to true here (actually, the equivalent in my version of Steal): https://github.com/stealjs/steal-less/blob/master/less.js#L24

Doing so reduced the number of HTTP request made by the less.js library from 171 to 10.

The app seemed to continue to work just fine.

From what I understand, setting this option by default will address https://github.com/stealjs/steal-less/issues/1.

matthewp commented 9 years ago

So it prevents re-fetching files that have already loaded? That makes sense. In reality the browser cache should handle duplicates anyways, but devs often turn the browser cache off. Sounds like a good fix to me!

matthewp commented 9 years ago

If you could make a PR for this it would be a great enhancement to get in.

akagomez commented 9 years ago

I can do that.

I've been using a branched version of my app with useFileCache set to true and I haven't noticed any issues.

nlundquist commented 8 years ago

This is now being done: https://github.com/stealjs/steal-less/blob/master/less.js#L26

And 'useFileCache' now defaults to true in Less.js > 2.0