Permalink
Browse files

Moving JS assets to bottom of the page for faster loadtimes.

  • Loading branch information...
1 parent 33ad0ea commit e2e0d1e09d96aa19f73431a9eff047b97ab5e955 @samuelclay committed Feb 28, 2012
Showing with 37 additions and 43 deletions.
  1. +2 −2 fabfile.py
  2. +3 −1 settings.py
  3. +11 −25 templates/base.html
  4. +20 −14 templates/reader/feeds.xhtml
  5. +1 −1 utils/jammit.py
View
@@ -71,7 +71,7 @@ def pull():
run('git pull')
def pre_deploy():
- compress_assets()
+ compress_assets(bundle=True)
def post_deploy():
cleanup_assets()
@@ -149,7 +149,7 @@ def kill_celery():
with cd(env.NEWSBLUR_PATH):
run('ps aux | grep celeryd | egrep -v grep | awk \'{print $2}\' | sudo xargs kill -9')
-def compress_assets():
+def compress_assets(bundle=False):
local('jammit -c assets.yml --base-url http://www.newsblur.com --output static')
local('tar -czf static.tgz static/*')
View
@@ -39,10 +39,12 @@
sys.path.append(UTILS_ROOT)
if '/vendor' not in ' '.join(sys.path):
sys.path.append(VENDOR_ROOT)
+
# ===================
# = Global Settings =
# ===================
+DEBUG = False
TEST_DEBUG = False
SEND_BROKEN_LINK_EMAILS = False
MANAGERS = ADMINS
@@ -60,7 +62,7 @@
SECRET_KEY = 'YOUR_SECRET_KEY'
EMAIL_BACKEND = 'django_ses.SESBackend'
CIPHER_USERNAMES = False
-
+DEBUG_ASSETS = DEBUG
# ===============
# = Enviornment =
View
@@ -62,17 +62,6 @@
</script>
{% include_stylesheets "common" %}
- {% block head_js %}
- {% include_javascripts "common" %}
- {% endblock head_js %}
- {% block extra_head_js %}
- {% endblock extra_head_js %}
-
- <script type="text/javascript" charset="utf-8">
- $.extend(NEWSBLUR.Preferences, {% if user_profile.preferences %}{{ user_profile.preferences|safe }}{% else %}{}{% endif %});
- $.extend(NEWSBLUR.Preferences['view_settings'], {% if user_profile.view_settings %}{{ user_profile.view_settings|safe }}{% else %}{}{% endif %});
- $.extend(NEWSBLUR.Preferences['collapsed_folders'], {% if user_profile.collapsed_folders %}{{ user_profile.collapsed_folders|safe }}{% else %}[]{% endif %});
- </script>
{% if not debug %}
<script type="text/javascript">
@@ -121,19 +110,16 @@
{% block content %}{% endblock %}
- {% if not debug %}
- <!-- Start Quantcast tag -->
- <script type="text/javascript">
- _qoptions={
- qacct:"p-0dE65XaLY51Og"
- };
- </script>
- <script type="text/javascript" src="http://edge.quantserve.com/quant.js"></script>
- <noscript>
- <img src="http://pixel.quantserve.com/pixel/p-0dE65XaLY51Og.gif" style="display: none;" border="0" height="1" width="1" alt="Quantcast"/>
- </noscript>
- <!-- End Quantcast tag -->
- {% endif %}
-
+ {% block head_js %}
+ {% include_javascripts "common" %}
+ {% endblock head_js %}
+ {% block extra_head_js %}
+ {% endblock extra_head_js %}
+
+ <script type="text/javascript" charset="utf-8">
+ $.extend(NEWSBLUR.Preferences, {% if user_profile.preferences %}{{ user_profile.preferences|safe }}{% else %}{}{% endif %});
+ $.extend(NEWSBLUR.Preferences['view_settings'], {% if user_profile.view_settings %}{{ user_profile.view_settings|safe }}{% else %}{}{% endif %});
+ $.extend(NEWSBLUR.Preferences['collapsed_folders'], {% if user_profile.collapsed_folders %}{{ user_profile.collapsed_folders|safe }}{% else %}[]{% endif %});
+ </script>
</body>
</html>
@@ -2,15 +2,29 @@
{% load typogrify_tags recommendations_tags utils_tags statistics_tags %}
-{% block content %}
+{% block extra_head_js %}
+ <script>
+ $(document).ready(function() {
-<script>
-$(document).ready(function() {
+ NEWSBLUR.reader = new NEWSBLUR.Reader();
- NEWSBLUR.reader = new NEWSBLUR.Reader();
+ });
+ </script>
+
+ {% if user.is_staff %}
+ <script>
+ $(document).ready(function() {
+ $('#add-feature-button').click(function(e) {
+ e.preventDefault();
+ $('#add-feature-form').fadeIn(500);
+ });
+ });
+ </script>
+ {% endif %}
+{% endblock %}
+
+{% block content %}
-});
-</script>
<h1 class="NB-splash-heading">NewsBlur</h1>
<h2 class="NB-splash-heading">- A visual feed reader with intelligence.</h2>
@@ -28,14 +42,6 @@ $(document).ready(function() {
<div class="NB-features-add">
<a href="#" id="add-feature-button" class="NB-splash-link">Add</a>
</div>
- <script>
- $(document).ready(function() {
- $('#add-feature-button').click(function(e) {
- e.preventDefault();
- $('#add-feature-form').fadeIn(500);
- });
- });
- </script>
{% endif %}
<div class="NB-spinner NB-left"></div>
<a href="#" class="NB-module-direction NB-module-next-page NB-javascript"></a>
View
@@ -36,7 +36,7 @@ def render_tags(self, asset_type, asset_package):
`use_compressed_assets` profile setting.
"""
tags = []
- if not settings.DEBUG:
+ if not getattr(settings, 'DEBUG_ASSETS', settings.DEBUG):
if asset_type == 'javascripts':
asset_type_ext = 'js'
elif asset_type == 'stylesheets':

0 comments on commit e2e0d1e

Please sign in to comment.