How to split components across domains with eZ Publish

The starting point of this post is an interesting asking of Marty_Nim (aka Nicolas Martinez) on Twitter about the ability to split static components across domains with eZ Publish to improve frontend performances.

Why split components across domains ?

Split components across domains is one of the advices of the Yahoo! Exceptionnal Performances team. This advice is a consequence of the behaviour of browsers that are able to download a limited number of compoments on a given domain at the same time. Following the RFC 2616, old browsers like Internet Explorer 6 or 7 are only able to download 2 components on a domain in parallel while modern browsers (Internet Explorer >=8, Firefox >=3.x, Chrome,…) are able to download 6 or 8 ressources in parallel. Therefore, this rule is especially useful for those old browsers or if your pages use a lot of different components. It's also not recommended to use too much different domains because of the DNS resolution latency.

In eZ Publish

In eZ Publish, it is very easy to implement this advice for JavaScript files and CSS stylesheets provided the ezjscore operators (ezcss* and ezscript* ) are used to include those files. In fact, the ezjscore extension allows to specify a custom hosts depending the extension of the included files. For instance, it's possible to write the following settings in an override of ezjscore.ini file:


With those settings, eZ Publish will include the JavaScript file(s) from , while CSS stylesheets will be included from . The later case has an interesting side effect, because the background images used in the CSS files will also be fetched from the custom host.

And what about others components that are directly embed in templates ? Currently, there's no out of the box solution, but as explained by Gaetano on Twitter, since eZ Publish 4.4, it's possible to override template operators so it's possible to write something similar for images, flash,… embed with ezimage, ezdesign or ezroot template operators even if this should probably be a native feature.