Pjax - Loading Different Page JS Files

I’ve been wanting to use Pjax to navigate between pages to speed up performance. It’s all good and well until I have javascript files used for that page only. Pjax only returns the html.

If I did an ajax call and returned the content in the controller using $this->renderAjax(‘myView’), the assets get returned and loaded correctly.

Is Pjax the right way to go about improving performance when I have different javascript files to be loaded on different pages? Ie. Can my entire application use pjax to correctly load and init assets between views to speed up performance.

Or is this just way too complex and I’m going about trying to improve performance in the wrong way?