Using jQuery in Custom Code with _strk

To achieve a better user experience for your site, we delay the loading of jQuery. To use jQuery in custom code, you must use _strk.

Instead of placing your jQuery code directly in the header or footer, you must subscribe to the page load event and then run the code there:

<script>
_strk.push('Page.didMount', function(){     /* your jQuery code goes here */ })
</script>

 

The full custom code should look something like this:

<script>
_strk.push('Page.didMount', function(){
    $(".s-section-1 h1").text(Math.random())
})
</script> 

 

On the other hand, if you do not use _strk, this code will NOT work:

<script>
/* This jQuery code will NOT work */ $(".s-section-1 h1").text(Math.random()) </script>

 

Note: _strk works in both site custom code and blog custom code.

Have more questions? Submit a request