What's the reason to include scripts with two different calls?

后端 未结 6 1910
小蘑菇
小蘑菇 2021-01-05 05:15

I use HTML5 boilerplate and jQuery is declared twice in the HTML page like this:



        
6条回答
  •  太阳男子
    2021-01-05 05:26

    If your question is "why is the transfer protocol not specified?," then the answer is "it doesn't have to be specified." This lets you use the same script reference regardless of whether the connection is using a secure socket or not without having your users receiving warnings about encrypted/unencrypted content.

    If the question was "what is this line doing?: window.jQuery || document.write('')," then the answer is that we are using a (more or less) ternary statement to test the jQuery object, which will evaluate to a "false" value if the jQuery library was not loaded, and if so, this test will trigger the second half of the statement, resulting in the local jQuery being loaded.

    HTH.

提交回复
热议问题