STATIC STUFF
Handling the Un-Django Parts of Your Django App
Matthew Tretter
@matthewwithanm
[email protected]
github.com/matthewwithanm
http://speakerdeck.com/matthewwithanm/django-static-stuff
Slide 2
Slide 2 text
Photo by Jeff Prouse http://www.flickr.com/photos/prousefamily/426140767/
Static files used to be a small
problem for Django devs
Slide 3
Slide 3 text
Photo by John R. Southern http://www.flickr.com/photos/krunkwerke/267608325
Now, they’re a much
larger problem
Slide 4
Slide 4 text
No content
Slide 5
Slide 5 text
⃠
Slide 6
Slide 6 text
No content
Slide 7
Slide 7 text
⃠
Slide 8
Slide 8 text
No content
Slide 9
Slide 9 text
Photo by Brin F http://thumbsandammo.blogspot.com/2013/03/blog-post_4297.html
{% load static from staticfiles %}
Delegates to
STATICFILES_STORAGE
Slide 15
Slide 15 text
main.css
main.af42991c673a.css
Wow, this slide is boring.
CachedStaticFilesStorage
CachedFilesMixin
Slide 16
Slide 16 text
You can’t tell your users to
clear their cache
Far-future FTW
Safer deployments
Photo by patriziasoliani http://www.flickr.com/photos/55524309@N05/5378314720/
Slide 17
Slide 17 text
Why not
django-compressor?
Slide 18
Slide 18 text
input defined in templates
doesn’t know about
dependency graphs
only for js & css
Slide 19
Slide 19 text
Embrace the build step
Photo by Phyllis Buchanan http://www.flickr.com/photos/pgautier/2598157781/
Slide 20
Slide 20 text
1.Collect the static files
from all apps into
temporary location
2.Perform the build
3.Collect the built files
Photo by Spencer Garness http://www.flickr.com/photos/njorthr/4030750472/
Slide 21
Slide 21 text
No content
Slide 22
Slide 22 text
sass/lessc
coffee
uglify.js
csso
Photo by Toni http://www.flickr.com/photos/toniandmatthew/5212240990/
Slide 23
Slide 23 text
sass/lessc
coffee
uglify.js
csso
Photo by Toni http://www.flickr.com/photos/toniandmatthew/5212240990/
r.js
jpegtran
pngcrush
svgo
Slide 24
Slide 24 text
sass/lessc
coffee
uglify.js
csso
r.js
jpegtran
pngcrush
svgo
ANYTHING
It’s still the same photo
Slide 25
Slide 25 text
Can we do better?
Yeah, still. Sorry.
Slide 26
Slide 26 text
Embrace Django
Slide 27
Slide 27 text
Photo by Brin F. But it’s slightly different than before! No it’s not. http://thumbsandammo.blogspot.com/2013/03/blog-post_4297.html