Forums / Developer / Smart loading of JavaScript / Comment50599
Łukasz Serwatka
Wednesday 21 January 2009 12:36:01 am
Hi,
In case when current view need JavaScript files and CSS files and other don't then you can load it when view template is processed.
Let's say that your fancy gallery require extra JavaScripy and CSS, then you can load JavaScript directly in gallery template using <script type="text/javascript" src={"javascript/script.js"|ezdesign}></script> which proper way of doing it. In case when you need CSS file in addition you can use persistent_variable to transport it to pagelayout.
{set scope=global persistent_variable=hash('css_file', 'mycssfile.css')}
You can also use JavaScript, e.g YAHOO.util.get() to load CSS programmatically.
Personal website -> http://serwatka.net Blog (about eZ Publish) -> http://serwatka.net/blog