They put all your JS inside <script>
tags with the onLoad
event code wrapped around it.
For example, if you choose to include jQuery and onLoad
then this is what jsfiddle will use:
<script type="text/javascript">
//<![CDATA[
$(window).load(function(){ /* your js here */ });
//]]>
</script>
If you don't include a library then they use:
<script type="text/javascript">
//<![CDATA[
window.onload=function(){ /* your js here */ }
//]]>
</script>
I presume they also use other library specific load
events depending on what you choose to include.
Using $(document).ready(function(){ });
isn't required when running your code in a fiddle.
Note: for a good explanation of what CDATA
is take a look at this answer - https://stackoverflow.com/a/7092306/2287470
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…