ccampbell / sonic

fast, lightweight PHP 5.3 MVC framework
http://www.sonicframework.com
Apache License 2.0
63 stars 11 forks source link

Adds simple resource dependency management and fixxes CSS flashing when loading new fragments #25

Closed gordyr closed 12 years ago

gordyr commented 12 years ago

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.

gordyr commented 12 years ago

Just so you're aware, please check out the most recent update to this pull request as in my previous two attempts i copied/pasted a working copy of the file accidentally. I'm still getting used to github!

gordyr commented 12 years ago

Reopened with correct changes.... Sorry!