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 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.

Need assistance? Start a conversation with our Support Team.
CONVERT MORE

Reliably Convert More Site Visitors, Even If Everything Else is Changing in Your Business.

START 15-DAY FREE TRIAL
✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features

Comments

  • Avatar
    Robert Kingston

    Judging from this, it sounds like any code inside the "Custom JavaScript" section only runs once, but code inside the "Code Editor" runs every 50ms. Is this correct?

  • Avatar
    Alex Kolenoff

    That is correct, Robert. The code in the Code Editor runs every 50ms up until document ready, and then just once more after that.

  • Avatar
    Brandon McConnell

    I believe the title of the article needs to be updated to include a period inside `convert_$`. I had a more difficult time finding the article because of this.

  • Avatar
    George Crewe

    Brandon, I added the period to the title. Thanks for the suggestion.

  • Avatar
    Brandon McConnell

    Thanks, George. The period's still in the wrong place though.. it should be convert._$ vs. convert.$

  • Avatar
    George Crewe

    Brandon, corrected.

  • Avatar
    Azad Rahman

    which approach will load faster?

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