Difference between revisions of "Loading jQuery for instrumenting pages"

From Market Ruler Help
Jump to: navigation, search
Line 23: Line 23:
  
 
* '''May 17, 2018''' - Added the <code>force</code> parameter to <code>__CR.jquery</code>
 
* '''May 17, 2018''' - Added the <code>force</code> parameter to <code>__CR.jquery</code>
 
+
* '''June 6, 2016''' - <code>__CR.jquery</code> publicly available as part of the [[:Category:ConversionRuler JavaScript Functions|JavaScript Functions]]
 
== See also ==
 
== See also ==
  

Revision as of 18:35, 17 May 2018

The __CR.jquery function takes two parameters; the first of which is a callback which has the first parameter the jQuery global (typically window.jQuery or window.$).

cr.jquery(loaded, force)

The second parameter is a boolean value which should be true to force the script to load a new version of jQuery from the ConversionRuler servers. You should only do this if an incompatible version of jQuery exists on the page.

Otherwise, the current version of jQuery which is loaded is 1.11.3. It is only loaded if jQuery is not detected on the page and the 2nd parameter is not true. Detection checks for the existence of the window.jQuery variable being defined.

An example of its usage is:

<script>
window._crq = window._crq || [];
window._crq.push(function (cr) {
    cr.jquery(function ($) {
        // Do jQuery stuff here using $ as the loaded version of jQuery
    });
});
</script>

For more information, read the jQuery documentation.

Revisions

  • May 17, 2018 - Added the force parameter to __CR.jquery
  • June 6, 2016 - __CR.jquery publicly available as part of the JavaScript Functions

See also