ccampbell/sonic — pull request #25 by gordyr (2012-07-06 12:06:01+00:00)
Title: Adds simple resource dependency management and fixxes CSS flashing when loading new fragments

This is my first pull request ever so I'm not sure i've done this right...

Anyway, the two minor changes I have made do the following:

1. Set visibility of fragment to 'hidden' until all CSS files are loaded
2. maintain log of all JS/CSS files and only load them if they aren't already present.

The second change is very useful if you are loading fragments dynamically as I am. i.e. You don't need to reload a full page, you just want to change a fragment (ajax navigation).

Previously if you did this all css/js files were reloaded and parsed a second time (even though they are cached by the browser), with this check in place Sonic will ignore the duplicate resources when loading in a fragment dynamically via an ajax request.

As an example, when a user logs in to my app they are taken to their control panel. This change doesn't require a page refresh, it simply requires a single fragment to be replaced. This change is performed via an ajax request which replaces the content.

This change dropped this request from 800+ms to approx 200-250ms.