Referencing jQuery before it's loaded

by peterbenoit

HTML

<html>
    
    <head>
        <script>
            function $$(method) {
                if (window.$) {
                    method();
                } else {
                    setTimeout(function() {
                        $$(method)
                    }, 50);
                }
            }
            
            function defer(method) {
                if (window.CDC) {
                    method();
                } else {
                    setTimeout(function() {
                        defer(method)
                    }, 50);
                }
            }

            $$(function() {
                $('div.body').prepend("<h1>jquery is loaded</h1>");
            });
        </script>
        <script src="http://www.cdc.gov/TemplatePackage/3.0/js/libs/modernizr-latest.js"></script>

    </head>
    
    <body>
        <div class="body">
            <!-- ng:repeat: paragraph, index in paragraphs -->
            <p class="paragraph ng-attr-widget" ng:repeat-index="0"><span ng:bind="paragraph.text" class="ng-directive ng-binding">Soufflé pastry dragée lemon drops sesame snaps brownie. Toffee marshmallow cake gingerbread tiramisu chocolate bar sugar plum. Cotton candy gingerbread jujubes dragée pudding. Chocolate cake cotton candy topping candy canes dragée candy lemon drops tootsie roll. Dessert lemon drops icing danish jujubes croissant jelly unerdwear.com. Ice cream chupa chups pie marshmallow. Biscuit brownie liquorice powder gingerbread gummi bears sugar plum pastry bonbon. Ice cream cupcake jelly beans applicake jelly beans. Jelly beans fruitcake icing. Gummies tiramisu jujubes tootsie roll lemon drops wafer gingerbread. Jelly oat cake donut unerdwear.com unerdwear.com sweet roll dessert fruitcake apple pie. Liquorice powder topping wafer.</span>
            </p>
            <script>
                $$(function() {
                    $('.paragraph2').css('color','red');
                });
                
                defer(function() {
 ...