# How to 'pjax' with bricks?

**URL:** <https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927>\
**Category:** How To\
**Created:** [August 29, 2021, 8:41pm UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927 "2021-08-29T20:41:59Z")\
**Posts on this page:** 18\
**Page:** 2

<div class="post-metadata">

**Author:** ![iredave](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/i/dfb087/32.png) [@iredave](https://forum.bricksbuilder.io/u/iredave)\
**Post date:** [October 12, 2022, 12:17pm UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/21 "2022-10-12T12:17:32Z")

</div>

let me know what errors are showing up in the console or send me a link to your site.

---

<div class="post-metadata">

**Author:** ![silent](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@silent](https://forum.bricksbuilder.io/u/silent)\
**Post date:** [October 12, 2022, 12:21pm UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/22 "2022-10-12T12:21:47Z")

</div>

i have deleted my test site. i would reinstall sure and test again. and, will return ofcourse here! thanks for ur interest to help.

---

<div class="post-metadata">

**Author:** ![MartinWB](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/martinwb/32/22977_2.png) [@MartinWB](https://forum.bricksbuilder.io/u/MartinWB)\
**Post date:** [October 30, 2022, 8:56pm UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/23 "2022-10-30T20:56:03Z")

</div>

Hi there,

I’ve tried barba.js with gsap and it works just fine.

Use this in function.php

```auto
add_filter( 'bricks/body/attributes', function( $attributes ) {
  // Add 'data-barba' HTML attribute to body with value 'wrapper'
  $attributes['data-barba'] = 'wrapper';
  return $attributes;
} );

add_filter( 'bricks/content/attributes', function( $attributes ) {
  // get page ID
  $id = get_the_ID();
  // Add 'data-barba' HTML attribute to main with value 'container'
  $attributes['data-barba'] = 'container';
  // Add 'data-barba-namespace' HTML attribute to main with current page id
  $attributes['data-barba-namespace'] = 'page-'.$id;
  return $attributes;
} );

```

then place this after footer

```
<script src="https://unpkg.com/@barba/core"></script>

<!-- load gsap animation library (minified version) -->
<script src="https://unpkg.com/gsap@latest/dist/gsap.min.js"></script>

<!-- init barba with transition -->
<script type="text/javascript">
  barba.init({
    transitions: [{
      name: 'transition',
      leave(data) {
        return gsap.to(data.current.container, {
          xPercent: -100
        });
      },
      enter(data) {
        return gsap.from(data.next.container, {
          xPercent: -100
        });
      }
    }]
  });
</script>

```

… just an example…you can continue with barb and gsap docs.

---

<div class="post-metadata">

**Author:** ![mikeanywhere](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@mikeanywhere](https://forum.bricksbuilder.io/u/mikeanywhere)\
**Post date:** [October 30, 2022, 11:58pm UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/24 "2022-10-30T23:58:32Z")

</div>

Looking forward to trying this! Cheers 🙂

---

<div class="post-metadata">

**Author:** ![mikeanywhere](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@mikeanywhere](https://forum.bricksbuilder.io/u/mikeanywhere)\
**Post date:** [November 2, 2022, 4:41pm UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/25 "2022-11-02T16:41:51Z")

</div>

Unfortunately this seems to suffer the same fate mentioned above. Transitions seem to work well, which is cool, but elements like the slider get lost en route, eventually resulting in a blank page.

Thanks for the input, though!

---

<div class="post-metadata">

**Author:** ![wplit](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/wplit/32/2730_2.png) [@wplit](https://forum.bricksbuilder.io/u/wplit)\
**Post date:** [November 3, 2022, 1:58am UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/26 "2022-11-03T01:58:58Z")

</div>

This is why I’ve always shied away from writing a tutorial on it. Fairly easy to implement originally, but all the potential issues come afterwards when you start adding plugins or trying to use elements that come with JS that needs to run at particular times to behave correctly.

It’d be one day of “hey nice tutorial” followed by wall of support questions coming my way for the next three years when it inevitably goes wrong for half of the Bricks users. 🤣

---

<div class="post-metadata">

**Author:** ![sebastianberger](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/sebastianberger/32/3447_2.png) [@sebastianberger](https://forum.bricksbuilder.io/u/sebastianberger)\
**Post date:** [November 3, 2022, 9:56am UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/27 "2022-11-03T09:56:36Z")

</div>

Maybe something of interest without Barba or swup?

> **[Morphing Page Transition | Codrops](https://tympanus.net/codrops/2017/08/08/morphing-page-transition/)**
>
> Today we'd like to share a simple morphing page transition effect with you. The idea is to morph an SVG path while movin

(ok, saw that anime.js will be loaded)  
or

> **[How To Fade Web Pages On Load And Unload (CSS + JS)](https://christopheraue.net/design/fading-pages-on-load-and-unload)**
>
> Fading web pages on load and unload creates a more pleasing experience for a website's visitors. It can be achieved with plain old html, a little bit of CSS and JS.

---

<div class="post-metadata">

**Author:** ![MartinWB](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/martinwb/32/22977_2.png) [@MartinWB](https://forum.bricksbuilder.io/u/MartinWB)\
**Post date:** [November 3, 2022, 1:05pm UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/28 "2022-11-03T13:05:50Z")

</div>

Hi Mike,

sure I know.

From what I’ve found it suppose to be used for static content.

Anyway you can initialize sliders or JS after transition but you need to know which parts need to be loaded again.

---

<div class="post-metadata">

**Author:** ![Karen](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/k/7feea3/32.png) [@Karen](https://forum.bricksbuilder.io/u/Karen)\
**Post date:** [December 18, 2022, 9:03am UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/29 "2022-12-18T09:03:21Z")

</div>

Please see also [https://highway.js.org/](https://highway.js.org/) by Dog Studio

---

<div class="post-metadata">

**Author:** ![Larsoss](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/larsoss/32/17658_2.png) [@Larsoss](https://forum.bricksbuilder.io/u/Larsoss)\
**Post date:** [February 16, 2024, 11:43am UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/30 "2024-02-16T11:43:52Z")

</div>

Hi, are there any updates on this?  
For example Elementor themes such as “Harington” ([Harington - Creative Portfolio Theme by ClaPat | ThemeForest](https://themeforest.net/item/harington-creative-portfolio-theme/42929633)) seem to have an AJAX loading option enabled, which enables the website to make use of Barba.js.

Isn’t there any way to implement this to Bricks Builder theme as well? I would love to find out how, since Bricks is now my go-to-theme / page builder and updates are so quickly developed.

---

<div class="post-metadata">

**Author:** ![MaxZieb](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/maxzieb/32/104_2.png) [@MaxZieb](https://forum.bricksbuilder.io/u/MaxZieb)\
**Post date:** [February 16, 2024, 1:23pm UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/31 "2024-02-16T13:23:41Z")

</div>

Sounds like a plugin territory to me. I am pretty sure that BricksForge has this approach covered… Furthermore, HTMX is also a great option … I was playing with it and there is a thread about it as well.

---

<div class="post-metadata">

**Author:** ![alvarin](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@alvarin](https://forum.bricksbuilder.io/u/alvarin)\
**Post date:** [March 25, 2024, 9:44am UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/32 "2024-03-25T09:44:31Z")

</div>

Any news here?  
I was able to integrate perfectly Barba with Elementor following this tutorial and with some after work:

> **[Create smooth page transitions using Barba.js w/ Wordpress, Elementor &...](https://thisisadvantage.com/page-transitions-using-barba-js-wordpress-elementor/)**
>
> It has been my life-long mission (or at least the last few months) to get smooth page transitions working with Wordpress themes and plugins like Elementor and

I remember that I’ve used a piece of code that re-fires widgets, do we have this possibility in Bricks?

I’m new to Bricks so I’m exploring how to do again.

---

<div class="post-metadata">

**Author:** ![MartinWB](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/martinwb/32/22977_2.png) [@MartinWB](https://forum.bricksbuilder.io/u/MartinWB)\
**Post date:** [March 25, 2024, 10:12am UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/33 "2024-03-25T10:12:41Z")

</div>

You may use my hint [here](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/23). But you will need to reinitialize bricks JS functions and make sure that CSS stylesheets are loaded globally.

---

<div class="post-metadata">

**Author:** ![alvarin](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@alvarin](https://forum.bricksbuilder.io/u/alvarin)\
**Post date:** [March 25, 2024, 10:24am UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/34 "2024-03-25T10:24:55Z")

</div>

Yes, that is the point. The piece of code I used with Elementor was something like this:

```auto
<script>
    jQuery(".elementor-element").each(function () {
        elementorFrontend.elementsHandler.runReadyTrigger(jQuery(this));
    });
</script>

```

is there any function like this or we should request it ?

---

<div class="post-metadata">

**Author:** ![MartinWB](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/martinwb/32/22977_2.png) [@MartinWB](https://forum.bricksbuilder.io/u/MartinWB)\
**Post date:** [March 25, 2024, 4:08pm UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/35 "2024-03-25T16:08:09Z")

</div>

It depends on what you want to run. Let say you may re-run interactions. You may use this in barba before enter:

```auto
beforeEnter(data) {
   bricksInteractionsFn.run();
},

```

Anyway you may run other bricks js functions depends on what you are using.

---

<div class="post-metadata">

**Author:** ![alvarin](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@alvarin](https://forum.bricksbuilder.io/u/alvarin)\
**Post date:** [March 25, 2024, 8:11pm UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/36 "2024-03-25T20:11:32Z")

</div>

Thanks Martin ! where did you find that function? I’m exploring dev documentation but I can’t find where, just in the bricks.min.js like  
`function bricksVideo() { bricksVideoFn.run() }`.  
I would like to know more about widget functions (like background video, gallery, posts…). When I did with Elementor with that line I shared I was able to re run everything on page so I’m looking for something similar but I suppose that one by one is also OK and a little more powerful 😉

After some experimentation also I’ll decide if going with barba, swup or htmlx. Barba seems a little outdated, swup is maintaned and htmlx is something fresh I’ve never try 😮  
Thanks again

---

<div class="post-metadata">

**Author:** ![MartinWB](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/martinwb/32/22977_2.png) [@MartinWB](https://forum.bricksbuilder.io/u/MartinWB)\
**Post date:** [March 26, 2024, 8:28am UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/37 "2024-03-26T08:28:53Z")

</div>

Well you have to try to see what will best suits your needs.

Anyway if you are thinking about htmx you may take a look at @sinanisler post: [Bricks + HTMX](https://forum.bricksbuilder.io/t/it-is-very-easy-to-make-page-transitions-with-bricks-htmx/19499)

---

<div class="post-metadata">

**Author:** ![JohnGalt](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/j/a587f6/32.png) [@JohnGalt](https://forum.bricksbuilder.io/u/JohnGalt)\
**Post date:** [June 25, 2024, 3:24pm UTC](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927/38 "2024-06-25T15:24:11Z")

</div>

My entire page implodes

[Previous page](https://forum.bricksbuilder.io/t/how-to-pjax-with-bricks/927.md?page=1)
