JavaScript中是否存在类似于@importCSS的内容,允许您在另一个JavaScript文件中包含JavaScript文件?
有许多使用jQuery在javascript/dom中实现某些功能的例子.但是,使用jQuery并不总是能够理解用jQuery编写的javascript解决方案的例子.
有没有一种简单的方法将jQuery代码转换为常规javascript?我想无需访问或理解jQuery源代码.
我正在为自己编写一个JavaScript工具,我计划向其他人提供它并使用jQuery.我对这个小实用程序的梦想是让人们能够.js从远程源中包含一个文件,并且在加载该文件时,让它检查是否已经包含jQuery,如果有,则确保它是一个最近的版本,以便与我的代码需要做的兼容.一些伪代码可以更清楚地解释我的问题(这段代码会出现在.js我之前提到的单个文件的顶部):
if jQuery is loaded {
if version is less than (say) 1.3 {
// load latest version of jQuery
}
} else {
// load latest version of jQuery
}
// and do the jQuery.noConflict()
// dance to avoid trampling any other libraries, etc. that the
// user may be utilizing.
// The rest of my code lives here, happy in the knowledge that it's running in
// isolation from the rest of the JS …Run Code Online (Sandbox Code Playgroud)