[ jquery ] jquery 활용 js 파일 include 하기 > javascript&jQuery

본문 바로가기
사이트 내 전체검색

javascript&jQuery

[ jquery ] jquery 활용 js 파일 include 하기

페이지 정보

작성자 웹지기 댓글 0건 조회 4,902회 작성일 18-09-27 17:08

본문

jquery를 이용해 js 파일들을 인클루드 하는 플러그인

먼저 include 해야할 js 파일을 한 후 순차적으로 js 파일을 인클루드


1. 기본환경설정

[code]

<script src="/common/js/jquery-1.7.1.min.js" ></script>

<script src="/common/js/jquery.extended.js" ></script>

[/code]


2. 사용법

    # 방법 1

[code]

$.include(

    'js/my.js', // my.js 로딩 후 my1.js 를 로딩함

    $.include('js/my1.js')

);

[/code]


    # 방법 2

[code]

$.include('js/my.js',

    // my.js를 먼저 로딩 후 my1.js, my2.js 를 불러 들입니다.

    [

        $.include('js/src/my1.js'),

        $.include('js/src/my2.js')

    ]

);

[/code]


@ jquery.extended.js 소스

[code]

/**

 * $.include - script inclusion jQuery plugin

 * Based on idea from http://www.gnucitizen.org/projects/jquery-include/

 * @author Tobiasz Cudnik

 * @link http://meta20.net/.include_script_inclusion_jQuery_plugin

 * @license MIT

 */

// overload jquery's onDomReady

if ( jQuery.browser.mozilla || jQuery.browser.opera ) {

    document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );

    document.addEventListener( "DOMContentLoaded", function(){ jQuery.ready(); }, false );

}

jQuery.event.remove( window, "load", jQuery.ready );

jQuery.event.add( window, "load", function(){ jQuery.ready(); } );

jQuery.extend({

    includeStates: {},

    include: function(url, callback, dependency){

        if ( typeof callback != 'function' && ! dependency ) {

            dependency = callback;

            callback = null;

        }

        url = url.replace('\n', '');

        jQuery.includeStates[url] = false;

        var script = document.createElement('script');

        script.type = 'text/javascript';

        script.onload = function () {

            jQuery.includeStates[url] = true;

            if ( callback )

                callback.call(script);

        };

        script.onreadystatechange = function () {

            if ( this.readyState != "complete" && this.readyState != "loaded" ) return;

            jQuery.includeStates[url] = true;

            if ( callback )

                callback.call(script);

        };

        script.src = url;

        if ( dependency ) {

            if ( dependency.constructor != Array )

                dependency = [dependency];

            setTimeout(function(){

                var valid = true;

                $.each(dependency, function(k, v){

                    if (! v() ) {

                        valid = false;

                        return false;

                    }

                })

                if ( valid )

                    document.getElementsByTagName('head')[0].appendChild(script);

                else

                    setTimeout(arguments.callee, 10);

            }, 10);

        }

        else

            document.getElementsByTagName('head')[0].appendChild(script);

        return function(){

            return jQuery.includeStates[url];

        }

    },

    readyOld: jQuery.ready,

    ready: function () {

        if (jQuery.isReady) return;

        imReady = true;

        $.each(jQuery.includeStates, function(url, state) {

            if (! state)

                return imReady = false;

        });

        if (imReady) {

            jQuery.readyOld.apply(jQuery, arguments);

        } else {

            setTimeout(arguments.callee, 10);

        }

    }

});

[/code]

추천0 비추천0

댓글목록

등록된 댓글이 없습니다.

Total 63건 3 페이지
  • 33 [ jquery ] 체크박스 제어
  • 체크여부 확인 - id가 동일한 체크박스에 대하여 선택되어 있는지 확인 : true / false 반환 $("#chkBox").is(":checked") ; $("input:checkbox[id='chkBox']").is(":checked") ; * 1.6이상일때 권장 사용법 $("#chkBox").prop("checked") ;체크박스 갯수 가져오기 - 선택된 체크박스 갯수 구하기 $(&#...
  • 웹지기 09-05 2733 0 0 댓글 0
  • 32 [ jquery ] 체크박스 체크확인
  • checked 여부 확인ID일 경우 ==&gt; $("input:checkbox[id='ID']").is(":checked") == true : falseNAME일 경우 ==&gt; $("input:checkbox[name='NAME']").is(":checked") == true : falsechecked/unchecked 처리ID일 경우 ==&gt; $("input:checkbox[id=...
  • 웹지기 09-05 2694 0 0 댓글 0
  • 31 [ jquery ] 등록, 수정, 삭제, 등등의 예제
  • [code]====================================================================================- function 명insXXX - 등록(예)insBoard()updXXX - 수정(예)updBoard()delXXX - 삭제(예)delBoard()getXXX - 모든 화면 이동(예)getBoardList(), getBoardView()saveXXX - 확인(예)saveBoard()chkXXX - 체크 chkBoard()rese...
  • 웹지기 09-27 1 0 0 댓글 0
  • 30 [ javascript ] 정규표현식, Regular Expressions(regex, regexp) in …
  • 관련 문서http://www.regexr.com/https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExphttp://blog.outsider.ne.kr/360http://regexlib.com/DisplayPatterns.aspxhttp://blog.eairship.kr/197http://tryhelloworld.co.kr/courses/정규표현식정규 표현식이란 문자열에서 특정한 캐릭터 조합을 찾아...
  • 웹지기 09-27 2740 0 0 댓글 0
  • 29 [ javascript ] 특수 문자 ( 이스케이프 시퀀스 )
  • JavaScript는 직접 입력할 수 없는 문자를 만들기 위해 문자열에 포함시킬 수 있는 이스케이프 시퀀스를 제공합니다.이스케이프 시퀀스다음 표에서는 일반적인 문자에 대한 이스케이프 시퀀스의 몇 가지 예를 보여 줍니다.유니코드 문자 값이스케이프 시퀀스의미범주\u0008\b백스페이스\u0009\t탭공백\u000A\n줄 바꿈(새 줄)줄 종결자\u000B\v(이 표 아래에 있는 정보 참조)세로 탭공백\u000C\f폼 피드공백\u000D\r캐리지 리턴줄 종결자\u0020공백공백\u0022\"큰따...
  • 웹지기 09-23 4337 0 0 댓글 0
  • 27 [ jquery ] 라이브러리 모음
  • http://ui.jquery.com/jQueryUI 플러그인http://trirand.com/jqgrid/jQuery Grid 플러그인http://malsup.com/jquery/form/jQuery Form 플러그인File uploadAjax File UploadjQUploaderMultiple File Upload pluginjQuery File StyleStyling an input type fileProgress Bar PluginForm ValidationjQuery Validation...
  • 웹지기 09-28 3505 0 0 댓글 0
  • 26 [ javascript ] 자바스크립트 함수 모음
  • [code]&lt;script language="javascrip"&gt;function 함수명(){ 소스}&lt;/script&gt;:::외부:::&lt;a href="#" onclick="alert('환영')"&gt; ▶ 버튼에 스크립트 삽입&lt;a href="javascript:alert('환영')"&gt; ▶ 버튼에 스크립트 삽입&lt;...
  • 웹지기 09-28 2615 0 0 댓글 0
  • 25 [ jquery ] 검색결과 리스트글 / jQuery 관련 URL 모음
  • 강좌가볍고 쉬운 Ajax - jQuery 시작하기-가볍고 쉬운 Ajax - jQuery 시작하기|작성자하루살이ibm 강좌 -jQuery로 작업하기, Part 1: 브라우저로 데스크톱 응용 옮기기ibm 강좌 -jQuery로 작업하기, Part 2: 내일 나올 웹 응용을 오늘 구현해보자ibm 강좌 -jQuery로 Ajax 개발을 단순화 하기ibm 강좌 -jQuery로 작업하기, 3부: jQuery와 Ajax로 RIA 만들기ibm 강좌 -Ajax로 사이트 전면 개편, Part 1: Ajax와 jQuer...
  • 웹지기 09-28 3644 0 0 댓글 0
  • 24 [jquery] jqeyry 튜토리얼 모음
  • 제이쿼리(JQuery)[jQuery] 001. 제이쿼리를 이용한 12달 달력 코딩하기Customizing and Theming jQuery UI Datepicker[미리보기][jQuery] 002.포토샵과 제이쿼리를 이용한 이미지 슬라이드 만들기Customizing and Theming jQuery UI Datepick[미리보기][jQuery] 003.페이지 번호를 통한 페이지 스크롤 바 만들기Extreme Makeover: jPaginator CSS3 Edition[미리보기][jQuery] 00...
  • 웹지기 09-28 3179 0 0 댓글 0
  • 23 [ jquery ] jquery 간단 정리
  • 기본 셀렉터[code]$("*") : 모두$("div p") : 모든 &lt;div&gt;에 포함된 모든 &lt;p&gt;$("#loginID") : id="loginID"$(".Columns") : class="Columns"$("p &gt; a") : &lt;p&gt;에 포함된 한 단계 아래 레벨의 모든 &#...
  • 웹지기 09-27 3056 0 0 댓글 0
  • 20 [ jquery ] jquery 강좌 및 참고 사이트 모음
  • 강좌http://www.taeyo.pe.kr/Columns/List.aspx?SEQ=29&amp;IDX=0비디오 강좌http://blog.themeforest.net/screencasts/jquery-for-absolute-beginners-video-series/예제http://www.webdesignerwall.com/tutorials/jquery-tutorials-for-designers/참고사이트http://webitect.net/tutorials/jquery-tutorial-pa...
  • 웹지기 09-27 2184 0 0 댓글 0
  • 열람중 [ jquery ] jquery 활용 js 파일 include 하기
  • jquery를 이용해 js 파일들을 인클루드 하는 플러그인먼저 include 해야할 js 파일을 한 후 순차적으로 js 파일을 인클루드1. 기본환경설정[code]&lt;script src="/common/js/jquery-1.7.1.min.js" &gt;&lt;/script&gt;&lt;script src="/common/js/jquery.extended.js" &gt;&lt;/script&...
  • 웹지기 09-27 4903 0 0 댓글 0
게시물 검색

회원로그인

접속자집계

오늘
6,153
어제
11,874
최대
33,828
전체
8,540,189

그누보드5
Copyright © funyphp.com. All rights reserved.