Skip to content

Commit

Permalink
Moving JS assets to bottom of the page for faster loadtimes.
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelclay committed Feb 28, 2012
1 parent 33ad0ea commit e2e0d1e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 43 deletions.
4 changes: 2 additions & 2 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def pull():
run('git pull')

def pre_deploy():
compress_assets()
compress_assets(bundle=True)

def post_deploy():
cleanup_assets()
Expand Down Expand Up @@ -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/*')

Expand Down
4 changes: 3 additions & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -60,7 +62,7 @@
SECRET_KEY = 'YOUR_SECRET_KEY'
EMAIL_BACKEND = 'django_ses.SESBackend'
CIPHER_USERNAMES = False

DEBUG_ASSETS = DEBUG

# ===============
# = Enviornment =
Expand Down
36 changes: 11 additions & 25 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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>
34 changes: 20 additions & 14 deletions templates/reader/feeds.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion utils/jammit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit e2e0d1e

Please sign in to comment.