We are always looking for ways to maximize performance, so when we moved our website to WordPress, we played around with some new techniques.
One of the new technologies we decided to try out was Head.js.
Head.js loads scripts like images and helps to use HTML5 and CSS3 safely. Additionally, it allows developers to target CSS for different screens, paths, states and browsers. And a 2.30 kb, it has a small footprint.
We managed to get Head.js to play nicely with WordPress‘ native wp_enqueue_script by wrapping the print_head_scripts and print_footer_scripts in a filter and capturing the output with an output buffer.
We then parse the contents of the buffer for external dependencies and string them together as an argument for head.js.
The results were so promising that we are using this method for all new content management installs.