Use Event Delegation
document.body
). Instead, the best course of action is to use event delegation. Here’s a very basic example of how you’d use event delegation with jQuery:
<body>
existed. As a result, it took me less than 30 minutes to implement AJAX page navigation. Event delegation makes AJAX page loads possible.
Use Pub/Sub to Signal Events
DomContentLoaded
. On an AJAX-heavy site, however, we may need to execute this functionality several times so we’ll need a signal for when the page changes and we’ll need to recreate these widgets.
publish
call and we’re letting any module subscribe and react to that event!
Use a Solid pushState Manager
Place a Notifier in a Consistent Location
Cache Request Results by URL
Know When Not to Use AJAX
preventDefault()
call and simply let the page load per normal.
Add comment