ccampbell / sonic

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

Ensures all CSS files are loaded before showing the injected fragment / Simple resource management #26

Open gordyr opened 12 years ago

gordyr commented 12 years ago

Two main changes:-

  1. Hides fragment until all CSS files added via the "addCss" method are loaded. from my apps homepag
  2. Simple resource management - Keeps a log of add JS/CSS files and checks against them before loading them. This is very useful when dynamically loading fragments via ajax calls in order to prevent repeated http requests.

e.g. When navigating from my applications 'welcome' page to 'user control panel' only a single fragment needs to be updated rather than a full page load. Therefore I perform an ajax request to get the html of the required fragment. With the above changes, the response of this request was reduced down to around 200ms from about 800ms. You can now essentially specify all required resources needed to render a fragment without repeating requests under any circumstance (ajax request or full page load).

NOTE: Please look at the full file from the latest 'commit' as it took me a while to get to grips with the way pull requests work in github. My apologies.