3 ms·
This is the same stuff I've been hearing for the past 5 years. I think a few things are changing though. The new Basecamp's speed is mind-blowing. One thing th
by firefoxman1 15y ago
This is the same stuff I've been hearing for the past 5 years.
I think a few things are changing though. The new Basecamp's speed is mind-blowing. One thing that interested me about their approach was that they claim to use static HTML whenever possible. This allows them to cache a single file and serve it to everyone.
So I may have to disagree with the age-old wisdom: "It’s important to keep your Javascript in external files where possible, since it allows the browser to cache the scripts and not load them on every page load!"
Why? With single-page apps I think we need to separate out "Javascript" into two categories: Actual code and templates. I've been playing around with the 37Signals approach, where I store the site-wide base template inside a script tag right in the body. Then I send a cache header the first time that HTML is requested to ensure it's only loaded once. Then page-specific (route-specific) templates and scripts are asynchronously loaded. So my actual "code" JS is still loaded with src="..." but templates aren't.
- shingen 15y agoI think the improvements 37 Signals has delivered on speed have a lot more to do with recent database optimization and hardware upgrades than anything to do with static js file serving.
- lyime 15y agoWe have been using handlebar.js templates that are pre-compiled into js objects in a single file. So you get the same benefits of browser caching for your views.