Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Django Static Stuff
Matthew Dapena-Tretter
July 10, 2013
Programming
6
6.3k
Django Static Stuff
Handling the Un-Django Parts of Your Django App
Matthew Dapena-Tretter
July 10, 2013
Tweet
Share
More Decks by Matthew Dapena-Tretter
See All by Matthew Dapena-Tretter
Isomorphic JS, Server-side Rendering, React & Rockefeller
matthewwithanm
3
190
The Life and Times of a React Component
matthewwithanm
1
110
Everyone's Happy: React, Server-side Rendering & SEO
matthewwithanm
2
1.1k
Conquering State
matthewwithanm
1
330
RequireJS in 15 Minutes
matthewwithanm
2
170
Other Decks in Programming
See All in Programming
Node-RED 3.0 新機能紹介
utaani
0
130
短納期でローンチした新サービスをJavaで開発した話/launched new service using Java
eichisanden
6
1.9k
Reactive Java Microservices on Kubernetes with Spring and JHipster
deepu105
1
160
Amazon ECSのネットワーク関連コストの話
msato
0
620
JetPackComposeは宣言型プログラミングパラダイムって実はよくわかってないんですが、別に使ってもいいんですよね、
conigashima
0
170
Android Tools & Performance
takahirom
1
430
開発速度を5倍早くするVSCodeの拡張機能を作った
purp1eeeee
2
140
UI Testing of Jetpack Compose Apps, AppDevCon
alexzhukovich
0
130
エンジニアによる事業指標計測のススメ
doyaaaaaken
1
180
Independently together: better developer experience & App performance
bcinarli
0
160
即、New Relic / New Relic NOW!
uzulla
0
270
Running Laravel/PHP on AWS (AWS Builders Day Taiwan 2022)
dwchiang
0
130
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
337
17k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.3k
Fantastic passwords and where to find them - at NoRuKo
philnash
27
1.5k
How GitHub (no longer) Works
holman
296
140k
Navigating Team Friction
lara
175
11k
YesSQL, Process and Tooling at Scale
rocio
157
12k
Creatively Recalculating Your Daily Design Routine
revolveconf
207
10k
Web development in the modern age
philhawksworth
197
9.3k
BBQ
matthewcrist
74
7.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
224
49k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
10
3.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
253
12k
Transcript
STATIC STUFF Handling the Un-Django Parts of Your Django App
Matthew Tretter @matthewwithanm m@tthewwithanm.com github.com/matthewwithanm http://speakerdeck.com/matthewwithanm/django-static-stuff
Photo by Jeff Prouse http://www.flickr.com/photos/prousefamily/426140767/ Static files used to be
a small problem for Django devs
Photo by John R. Southern http://www.flickr.com/photos/krunkwerke/267608325 Now, they’re a much
larger problem
None
⃠
None
⃠
None
Photo by Brin F http://thumbsandammo.blogspot.com/2013/03/blog-post_4297.html
⃠ {% load static %}
def static(path): return settings.STATIC_URL + path
{% load staticfiles %}
{% load static from staticfiles %}
{% load static from staticfiles %} Delegates to STATICFILES_STORAGE
main.css main.af42991c673a.css Wow, this slide is boring. CachedStaticFilesStorage CachedFilesMixin
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/
Why not django-compressor?
input defined in templates doesn’t know about dependency graphs only
for js & css
Embrace the build step Photo by Phyllis Buchanan http://www.flickr.com/photos/pgautier/2598157781/
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/
None
sass/lessc coffee uglify.js csso Photo by Toni http://www.flickr.com/photos/toniandmatthew/5212240990/
sass/lessc coffee uglify.js csso Photo by Toni http://www.flickr.com/photos/toniandmatthew/5212240990/ r.js jpegtran
pngcrush svgo
sass/lessc coffee uglify.js csso r.js jpegtran pngcrush svgo ANYTHING It’s
still the same photo
Can we do better? Yeah, still. Sorry.
Embrace Django
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
generate & consume static file manifests tweak post-processing improve collection
TL;DL
{% load staticfiles %}
Hashes in Filenames
Embrace the build step
Build on staticfiles app
Thanks http://speakerdeck.com/matthewwithanm/django-static-stuff https://gist.github.com/matthewwithanm/5969795 Matthew Tretter @matthewwithanm m@tthewwithanm.com github.com/matthewwithanm