Hacker News new | ask | show | jobs
by rolae 2316 days ago
Intercooler is all about getting HTML into your DOM that you get from AJAX requests without actually writing any Javascript. Alpine is more about Interactivity within the current page, without doing a request first. It keeps the state in a data object.

Of course you can do similar things as you would do in Intercooler, but it would be explicit in the Javascript part. See this example they give for prefetching dropdown content from the server

    <div x-data="{ open: false }">
        <button
            @mouseenter.once="
                fetch('/dropdown-partial.html')
                    .then(response => response.text())
                    .then(html => { $refs.dropdown.innerHTML = html })
            "
            @click="open = true"
        >Show Dropdown</button>

        <div x-ref="dropdown" x-show="open" @click.away="open = false">
            Loading Spinner...
        </div>
    </div>