Optimize WordPress Script Loading with Head.js

Javascript & jQuery Development

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.

Performance Gains from Head.js

Performance Gains from Head.js

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.

About Cody Swann

Cody Swann is an entrepreneur, developer, strategist, banged up ex-football walk-on, retired body builder and former journalist born and raised in South Florida. He currently splits his time between his hometown of Stuart, FL and Los Angeles, CA. Cody founded Gunner Technology, a highly sought after digital agency, specializing in helping companies maximize profits through custom web development, technology efficiencies, social media strategy and search engine marketing. As a manager and developer at ESPN for nearly six years, Cody led development and vision for two of ESPN’s most popular online features: Sports Scoreboards and GameCasts. Additionally Cody oversaw all aspects of MyESPN and ESPN’s social network, ESPN Fan Profiles. Cody worked with Technology, Editorial, Sales, Marketing and relevant business stakeholders to mold ESPN’s social media strategy, develop custom applications for it and execute it. Under his direction, ESPN successfully ported large portions of its core product from a proprietary Java stack to an open source Ruby on Rails stack, capable of standing up and performing under the tremendous load world's most popular sports site delivers. Cody began forging his technological knowledge more than 10 years ago, developing and designing websites in college. His development work has included web development, web design, content writing, digital photography and digital video production for award-winning sites like Gainesville.com, GatorSports.com and ESPN.com. He has helped set digital strategy and direction for companies in the New York Times Regional Newspaper group, ESPN, ABC and Disney. He is a recognized expert in web development, social media strategy, search engine optimization, conversion optimization, analytics tracking and business planning. He has worked with large interactive media companies to small and medium sized businesses. Cody motivates and inspires creative teams to deliver superb, polished work under tight deadlines.

Leave a Reply