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 releases of SiteVision, hence it's strongly adviced to migrate existing scripts as soon as possible.

Do you want to subscribe to News from SiteVision Developer team? Subscribe here!