svDocReady to the rescue
Or how to get ready for Sitevision 5's blazing fast page rendering.
Using svDocReady to defer execution of inline javascripts
To decrease loading times and increase the overall responsiveness of content created in Sitevision. All javascripts* will be loaded at the end of the body-element in Sitevision 5, as per best-practice for building modern well performing web sites. This implies that previously available javascript libraries (like jQuery) will no longer be available for inline scripting.
To ease the transition to Sitevision 5 we are releasing the svDocReady utility in Sitevision 4.5.4, so developers and site maintainers can migrate their inline scripts in advance of the upgrade to Sitevision 5. The svDocReady utility is a wrapper for javascript that defers execution until after the document ready event. Scripts registered in svDocReady is guaranteed to execute after all of Sitevisions standard components and third party libraries are loaded and ready for use. Moving to use svDocReady is extremely simple and almost completely without risk.
Example of code before svDocReady
$svjq(function() {
$svjq('.myclass').on('click', function() {
//doing stuff
});
});
$svjq('body').append('Hello World of Sitevision');
After conversion:
svDocReady(function() {
$svjq('.myclass').on('click', function() {
//doing stuff
});
$svjq('body').append('Hello World of Sitevision');
});
* There will be a legacy-mode that's enabled by default after the upgrade to Sitevision 5, so freshly converted sites will still have jQuery and the $svjq variable available for inline scripting. Legacy-mode will be removed in future major releases of Sitevision, hence it's strongly adviced to migrate existing scripts as soon as possible.