How can a third party developer add a jQuery library to Magento 2?
While Magento 2 includes a version of jQuery in their frontend themes, the jQuery object is not immediately available in the global namespace. I belive this is because Magento 2 uses RequireJS to pull in jQuery, and RequireJS won't load a module file until its needed.
This presents a problem for jQuery plugins. Normally, I'd include a plugin with HTML that looked something like this
This, however, is not possible with Magento 2. Because the
jquery.cookie.js file defines the jQuery plugin by using the global jQuery object, it will fail in Magento 2 with a
jQuery is not defined error.
How should a front end developer include a standard jquery plugin library in Magento 2's front end application?