convert._$ vs. convert.$

 

Important

For these libraries to work, JQuery has to be enabled on the script or be included outside it.

CONVERT._$ - use it inside Code Editor

convert._$ is a jQuery reference modified in such a way so that the variation code can be executed multiple times while the page is still loading. We execute the code every 50 ms until there's nothing left inside the code that seems to need processing, or until DOM ready is hit. Let's have an example to understand how it works:

convert._$("a.login").text("Login here");
convert._$("a.loginFooter").text("Login");

We would execute this code immediately as our script finishes loading. It's very likely that is at the very beginning of the page load when not all the page was rendered yet. Let's suppose, at the moment of the first run, the a.login is available but a.loginFooter is not available. The effect of the code would be that the text of the a.login link would be changed to "Login here".

After another 50 ms, we run the code again since there's one element that was not found. This time, the a.loginFooter is available and its text is changed to"Login"; the a.login is not changed again since it was changed before.

As can be noticed, we wrapped the jQuery library into our own convert._$ function so that we can intercept the elements look-ups and know when the code "finished executing".

This allows us to run the code and change the elements without waiting for the DOM ready (which would ensure everything was loaded) since that takes time and users would experience a flickering effect (old version visible and then swapped with the new version).

CONVERT.$ - use it inside Custom Javascript

convert.$ exposes the unmodified version of Jquery for you to use, without the benefits of the modified version.