현재 수정할 수없는 기존 웹 페이지에 삽입 할 수있는 JavaScript 애플리케이션을 개발하려고합니다. 응용 프로그램에는 특정 버전의 jQuery가 필요합니다. 응용 프로그램을로드하는 데 사용동적으로로드 된 JavaScript 애플리케이션에서 jQuery 충돌 방지
스크립트가하고있는 다음
// loading JavaScript needed by my application
(function() {
document.write('<script src="../jquery-1.10.2.min.js"></script>');
document.write(...); // load other scripts (using jQuery 1.10.2)
// storing the application's jQuery in a new namespace
// to avoid conflicts with other jQuery versions
document.write('<script type="text/javascript">' +
'appJQ = jQuery.noConflict(true);</script>'); // error: jQuery is undefined in IE<10
})();
// initializing the application itself
document.onload = function() {
// ...
};
이 IE 9에서 IE < (10)를 제외하고, 내가 테스트 한 모든 브라우저에서 잘 작동하고 내가 오류를 얻고있다 절감이 jQuery는 정의되지 않았습니다.
document.onload
함수에서 새 네임 스페이스로 jQuery를 이동해도 다른 버전의 jQuery가 필요하면 내 응용 프로그램을 포함하는 웹 페이지의 다른 스크립트와 충돌이 발생합니다.
이 문제를 해결하는 방법에 대한 의견이 있으십니까? 도움 주셔서 감사합니다.
감사합니다. RequireJS를 사용하면 문제가 해결됩니다. –