diff options
author | Dan McGee <dan@archlinux.org> | 2013-02-16 20:54:11 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2013-02-16 20:54:11 +0100 |
commit | 51a6669c3c8a44b6b9e7fd09f8253d3a36953eb6 (patch) | |
tree | cddb149d39261cae22388e3d330895b706ae7be1 /templates | |
parent | 5bc85244281efc916132c86046018d0ebe70b5e9 (diff) | |
download | archweb-51a6669c3c8a44b6b9e7fd09f8253d3a36953eb6.tar.gz archweb-51a6669c3c8a44b6b9e7fd09f8253d3a36953eb6.tar.xz |
Defer loading of some JS on public index page
We don't need typeahead and easter eggs working right away, so defer
them into a onload event.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/public/index.html | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/templates/public/index.html b/templates/public/index.html index 89aa3b8..dad6a05 100644 --- a/templates/public/index.html +++ b/templates/public/index.html @@ -212,10 +212,8 @@ <div id="konami" style="display:none;"></div> {% load cdn %}{% jquery %} -<script type="text/javascript" src="{% static "bootstrap-typeahead.min.js" %}"></script> -<script type="text/javascript" src="{% static "konami.min.js" %}"></script> <script type="text/javascript"> -$(document).ready(function() { +function setupTypeahead() { $('#pkgsearch-field').typeahead({ source: function(query, callback) { $.getJSON('/opensearch/packages/suggest', {q: query}, function(data) { @@ -227,8 +225,8 @@ $(document).ready(function() { menu: '<ul class="pkgsearch-typeahead"></ul>', items: 10 }).attr('autocomplete', 'off'); -}); -$(document).ready(function() { +} +function setupKonami() { var konami = new Konami(function() { $('#konami').html('<img src="{% static "vector_tux.png" %}" alt=""/>'); setTimeout(function() { @@ -238,6 +236,10 @@ $(document).ready(function() { $('#konami').fadeOut(500); }); }); +} +$(document).ready(function() { + $.ajax({ url: "{% static "bootstrap-typeahead.min.js" %}", cache: true, dataType: "script", success: setupTypeahead }); + $.ajax({ url: "{% static "konami.min.js" %}", cache: true, dataType: "script", success: setupKonami }); }); </script> {% endblock %} |