convert_$ vs. convert.$

In this article we will explain the differences between convert_$ and convert.$

 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 loaded. We execute the code every 50 ms until there's nothing left inside the code that seems to need processing. 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 likelly that's in the very beginning of the page load when not all the page was rendered yet. Let's suppose, at the moment of 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 flicking effect (old version visible and than swapped with 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.

Have more questions? Submit a request

Comments