jquery如何包含.js文件

时间:2014-01-31 15:50:08

标签: jquery

当我通过浏览器中的查看源检查stackoverflow或flipkart.com网站代码时,我看到了 喜欢那个

<script type="text/javascript">
    StackExchange.init({
        "locale": "en",
        "stackAuthUrl": "https://stackauth.com",
        "serverTime": 1391174565,
        "styleCode": true,
        "enableUserHovercards": true,
        "site": {
            "name": "Stack <br/>Overflow",
            "description": "Q&A for professional and enthusiast programmers",
            "isNoticesTabEnabled": true,
            "recaptchaPublicKey": "6LdchgIAAAAAAJwGpIzRQSOFaO0pU6s44Xt8aTwc",
            "recaptchaAudioLang": "en",
            "nonAsciiTags": true,
            "enableSocialMediaInSharePopup": true
        },
        "user": {
            "fkey": "64a9dd799b4d7de695f9ab92904f258d",
            "isAnonymous": true
        }
    });
    StackExchange.using.setCacheBreakers({
        "js/prettify-full.en.js": "e0bbd4760e83",
        "js/moderator.en.js": "f24049d774be",
        "js/full-anon.en.js": "9f2bf11519b2",
        "js/full.en.js": "9fbd88448c92",
        "js/wmd.en.js": "849f408083f3",
        "js/third-party/jquery.autocomplete.min.js": "e5f01e97f7c3",
        "js/third-party/jquery.autocomplete.min.en.js": "",
        "js/mobile.en.js": "f979992d139c",
        "js/help.en.js": "d3cc74d8a93a",
        "js/tageditor.en.js": "6d51a5f8d7f3",
        "js/tageditornew.en.js": "5761dfb80bd0",
        "js/inline-tag-editing.en.js": "f951bd09dc69",
        "js/revisions.en.js": "33fd38144303",
        "js/review.en.js": "44c8a0044283",
        "js/tagsuggestions.en.js": "e4e7b952fcc7",
        "js/post-validation.en.js": "c275fe37d674",
        "js/explore-qlist.en.js": "73825bd006fc",
        "js/events.en.js": "c3218f63807f"
    }); < br / > StackExchange.using("gps", function () { < br / > StackExchange.gps.init(true); < br / >
    }); < br / >
</script>


我想开发我的Web应用程序,所以我也包含像这种模式的.js文件

请帮助

感谢

1 个答案:

答案 0 :(得分:1)

实际上这些都是基于自定义JavaScript文件。如果您要创建自己的网站,可以创建自定义js插件。在哪里创建一些方法并根据自己的用途执行它们!

您可能会看到这个jQuery源代码示例:

$(document).ready(function () {
   // remaining methods in this!
})

与此SE源代码类似。他们正在初始化代码,然后让用户有机会玩一些方法!

就StackExchange和Flipcart而言,他们有一组开发人员共同创建这些插件。这是一项时间和团队合作的工作!

因此,最好先了解如何以及何时加载JavaScript,而不是创建像这样的插件!

祝你好运。