Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Django Static Stuff
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Matthew Dapena-Tretter
July 10, 2013
Programming
8.6k
6
Share
Django Static Stuff
Handling the Un-Django Parts of Your Django App
Matthew Dapena-Tretter
July 10, 2013
More Decks by Matthew Dapena-Tretter
See All by Matthew Dapena-Tretter
Isomorphic JS, Server-side Rendering, React & Rockefeller
matthewwithanm
3
230
The Life and Times of a React Component
matthewwithanm
1
210
Everyone's Happy: React, Server-side Rendering & SEO
matthewwithanm
2
1.2k
Conquering State
matthewwithanm
1
380
RequireJS in 15 Minutes
matthewwithanm
2
210
Other Decks in Programming
See All in Programming
dRuby over BLE
makicamel
1
280
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
170
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.4k
3Dシーンの圧縮
fadis
1
570
inferと仲良くなる10分間
ryokatsuse
1
330
CSC307 Lecture 17
javiergs
PRO
0
310
tsserverとは何だったのか、これからどうなるのか
nowaki28
1
430
ビジネスモデルから紐解く、AI+型駆動開発
hirokiomote
2
5.1k
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
540
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
4
1.3k
AIエージェントの隔離技術の徹底比較
kawayu
0
450
関係性から理解する"同一性"の型用語たち
pvcresin
2
630
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
190
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
44k
Designing for Timeless Needs
cassininazir
1
240
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
The Pragmatic Product Professional
lauravandoore
37
7.3k
Scaling GitHub
holman
464
140k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
380
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
55k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Transcript
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
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
[email protected]
github.com/matthewwithanm