Вы можете проверить это, проверив внутренний фрейм или войдя в документ innerHTML
. Например, добавьте это к своему коду:
console.log(document.documentElement.innerHTML);
и вы получите
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- LOOK HERE: ----------------------------------------------------------------->
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.3.js"></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style id="compiled-css" type="text/css">
textarea{
display:block;
width: 100%;
height: 200px;
}
input{
display:block;
width: 100%;
}
</style>
<!-- TODO: Missing CoffeeScript 2 -->
<script type="text/javascript">//<![CDATA[
// LOOK HERE: ---------------------------------------------------------------------
$(window).load(function(){
console.log(document.documentElement.innerHTML);
$("textarea, input").bind("paste", function(e){
e.stopPropagation();
e.preventDefault();
var cd = e.originalEvent.clipboardData;
var text = cd.getData("text/plain");
$(this).val(text.trim());
});
});
//]]></script>
</head>
<body>
<textarea id="pastezone" placeholder="Copy someting with leading and trailing spaces here, then it gets trimmed!"></textarea>
<input id="pastebox" placeholder="Copy someting with leading and trailing spaces here, then it gets trimmed!">
<script>
// tell the embed parent frame the height of the content
if (window.parent && window.parent.parent){
window.parent.parent.postMessage(["resultsFrame", {
height: document.body.getBoundingClientRect().height,
slug: ""
}], "*")
}
// always overwrite window.name, in case users try to set it manually
window.name = "result"
</script>
</body>
Как видите, библиотека (jQuery) загружается немедленно , в теге <script>
в голове. Напротив, ваш код помещается внутри обратного вызова $(window).load(function(){
.
Обратите внимание, что метод запуска кода при запуске документа зависит от используемой библиотеки. Например, если вы отмените выбор jQuery и используете D3. js (или любую другую библиотеку вместо этого), вместо этого ваш код будет помещен в обратный вызов window.onload = function() {
.