admin管理员组文章数量:1406943
What is the simplest way to bine JavaScript files into a single file in a Django project?
Explanation
I want this to work with Ember.js/Backbone where you (usually) have many different JavaScript in multiple directories. Directories would all be in one folder called app/ for example, like: app/views/ app/models/ /app/routers/
Requirements
- Work together with the staticfiles app
- Still be separated while in development mode for easier debugging (only pile when calling collectstatic?)
- Work with Require.js (guess that shouldn't be too hard, but putting it in here to be sure)
Extra credit
Explain a best practices way of bining Django and Ember/Backbone.
What is the simplest way to bine JavaScript files into a single file in a Django project?
Explanation
I want this to work with Ember.js/Backbone where you (usually) have many different JavaScript in multiple directories. Directories would all be in one folder called app/ for example, like: app/views/ app/models/ /app/routers/
Requirements
- Work together with the staticfiles app
- Still be separated while in development mode for easier debugging (only pile when calling collectstatic?)
- Work with Require.js (guess that shouldn't be too hard, but putting it in here to be sure)
Extra credit
Explain a best practices way of bining Django and Ember/Backbone.
Share Improve this question edited Dec 15, 2011 at 23:51 Yehuda Katz 28.7k12 gold badges90 silver badges92 bronze badges asked Dec 15, 2011 at 19:49 c4urselfc4urself 4,28722 silver badges34 bronze badges3 Answers
Reset to default 4I am an happy user of django pressor, it does bine, minify, debug-friendly, you can use it with staticfiles, easy to plug with custom storage backend (eg. S3)
https://github./jezdez/django_pressor
The reason you want to bine many files into one is so to minimize latency of setting up and tearing down http requests, the fewer you make the better. However, many newer browsers are downloading JavaScript files in parallel (still executing sequentially). The consequence is that downloading a single 1Mb file may be slower than three 350Kb files.
you can use from CDNs.
As mentioned in the previous answer, django-pressor is nice, but you often get better loading times when using a dedicated javascript loader instead. My tip is to check out Head.js for example (http://headjs./) (there are tons other out there as well). Often bining scripts can be contra productive when considering caching, using javascript located on CDN:s etc.
One thing to remember is that Iphone 3/4 will just cache 15/25KB of javascript, so if you have huge scripts and bine them you can run into trouble. http://www.phpied./iphone-caching/
版权声明:本文标题:Combining and Compressing multiple JavaScript files into a single file in a Django project - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744940930a2633478.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论