July, 2010 Archives
29
Jul
Jul
My first github project!
by jon beebe in Software, Web Development
No Comments
Dynamic page head
Over the past few years I’ve had a need for dynamically adding/modifying the html <head> element as php builds pages. I created a singleton object for this purpose, and I’ve finally massaged the code to a point where it’s ready to release into the wild. My dynamic page head class comes with some convenient features such as:
- Add linked js/css and inline scripts and styles
- Optionally render javascript to the bottom of the DOM, as Yahoo’s YSlow recommends
- Merge files together, reducing requests to the server
- Minimize css with csstidy or YUI Compressor
- Minimize javascript with jsmin or YUI Compressor
- Optionally include/exclude any css or js asset from merging/minimization
- This is useful when including items such as TinyMCE, which uses javascript to include other assets. Minimization will break relative references to these items because the TinyMCE script will, mosty likely, not live in the same directory once minimized.
- Convenience functions for certain items such as nocache metadata
- Operate in xhtml (default) or html mode, rendering valid markup for either
