Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Django Static Stuff
Search
Matthew Dapena-Tretter
July 10, 2013
Programming
6
8.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
220
The Life and Times of a React Component
matthewwithanm
1
180
Everyone's Happy: React, Server-side Rendering & SEO
matthewwithanm
2
1.2k
Conquering State
matthewwithanm
1
350
RequireJS in 15 Minutes
matthewwithanm
2
190
Other Decks in Programming
See All in Programming
Why Kotlin? 電子カルテを Kotlin で開発する理由 / Why Kotlin? at Henry
agatan
2
6.2k
FluorTracer / RayTracingCamp11
kugimasa
0
180
手が足りない!兼業データエンジニアに必要だったアーキテクチャと立ち回り
zinkosuke
0
370
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
180
TypeScript 5.9 で使えるようになった import defer でパフォーマンス最適化を実現する
bicstone
1
1k
『実践MLOps』から学ぶ DevOps for ML
nsakki55
2
550
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
230
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
120
著者と進める!『AIと個人開発したくなったらまずCursorで要件定義だ!』
yasunacoffee
0
110
AIコーディングエージェント(Gemini)
kondai24
0
150
堅牢なフロントエンドテスト基盤を構築するために行った取り組み
shogo4131
6
1.9k
TypeScriptで設計する 堅牢さとUXを両立した非同期ワークフローの実現
moeka__c
6
2.9k
Featured
See All Featured
Bash Introduction
62gerente
615
210k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
690
Why You Should Never Use an ORM
jnunemaker
PRO
60
9.6k
Statistics for Hackers
jakevdp
799
230k
How GitHub (no longer) Works
holman
316
140k
Documentation Writing (for coders)
carmenintech
76
5.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
The Invisible Side of Design
smashingmag
302
51k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.8k
A Modern Web Designer's Workflow
chriscoyier
697
190k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
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