Disabling extra turbo-links code

Hi,

I know turbolinks support is baked in, however it would be really nice to maybe have a config item e.g. 'turbolinks' => false which does things like leaves out the stuff like…

var firstTime = true;
    document.addEventListener("turbolinks:load", function() {
        /* We only want this handler to run AFTER the first load. */
        if  (firstTime) {
            firstTime = false;
            return;
        }

        window.livewire.restart();
    });

    document.addEventListener("turbolinks:before-cache", function() {
        document.querySelectorAll(`[wire\\:id]`).forEach(el => {
            const component = el.__livewire;

            const dataObject = {
                data: component.data,
                events: component.events,
                children: component.children,
                checksum: component.checksum,
                name: component.name,
                errorBag: component.errorBag,
                redirectTo: component.redirectTo,
            };

            el.setAttribute('wire:initial-data', JSON.stringify(dataObject));
        });
    });

Is this something that would be considered?

Thanks

1 Like

I was thinking about the same. It would be better to add a config for turbolinks.