Select2 is easier to initialize on the HTML <select > element. You can either use static data or load data remotely using ajax
option.
Requires to return response in a defined format to load content using AJAX.
In this tutorial, I show how you can load data remotely in a select2 in CodeIgniter 3 project.