jQuery in Bricks

Bricks does not load jQuery out of the box on the front end.

It is possible that certain plugins do and this can be checked by viewing any page’s source (better to do incongito) and searching for jquery.

If for whatever reason you need to run some custom jQuery script, first check if you can re-write in vanilla JavaScript. If that is not an option, see if jQuery is already being loaded. If it is not, here’s how you can enqueue jQuery:

Add this in your child theme’s functions.php or a code snippets plugin:

wp_enqueue_script( 'jquery' );

That will load jQuery which WordPress comes bundled with.

To run your script when editing a template or Page with Bricks go to Settings (gear icon) → PAGE SETTINGS → CUSTOM CODE and add your code like this:

<script>
jQuery(document).ready(function($) {
    // code comes here
    console.log('test')
});
</script>

With that, if you see test in your browser’s developer tools console it means your jQuery script is working.

Instant access to 390+ Bricks code tutorials with BricksLabs Pro

Leave the first comment