A website may want to request knockout and jQuery via a <script /> include to a global CDN, for performance and cross-site caching benefits. And the same website may also wish to include Knockstrap via npm, being something that adds plugins to knockout.
However, in this instance, knockstrap fails to initialise because it's knockout / jQuery require statements conflict and, since it was called in the context of 'require()', it will not fallback to the global ko and $ variables.
As a side note, the $ variable should be referenced as jQuery, in case the site is in jQuery's noConflict mode.
A website may want to request knockout and jQuery via a
<script />
include to a global CDN, for performance and cross-site caching benefits. And the same website may also wish to include Knockstrap vianpm
, being something that adds plugins to knockout.However, in this instance, knockstrap fails to initialise because it's knockout / jQuery
require
statements conflict and, since it was called in the context of 'require()', it will not fallback to the globalko
and$
variables.As a side note, the
$
variable should be referenced asjQuery
, in case the site is in jQuery'snoConflict
mode.