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

This commit is contained in:
Samuel Clay 2012-02-28 12:17:38 -08:00
parent 33ad0ea5f6
commit e2e0d1e09d
5 changed files with 38 additions and 44 deletions

4
fabfile.py vendored
View file

@ -71,7 +71,7 @@ def pull():
run('git pull') run('git pull')
def pre_deploy(): def pre_deploy():
compress_assets() compress_assets(bundle=True)
def post_deploy(): def post_deploy():
cleanup_assets() cleanup_assets()
@ -149,7 +149,7 @@ def kill_celery():
with cd(env.NEWSBLUR_PATH): with cd(env.NEWSBLUR_PATH):
run('ps aux | grep celeryd | egrep -v grep | awk \'{print $2}\' | sudo xargs kill -9') 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('jammit -c assets.yml --base-url http://www.newsblur.com --output static')
local('tar -czf static.tgz static/*') local('tar -czf static.tgz static/*')

View file

@ -39,10 +39,12 @@ if '/utils' not in ' '.join(sys.path):
sys.path.append(UTILS_ROOT) sys.path.append(UTILS_ROOT)
if '/vendor' not in ' '.join(sys.path): if '/vendor' not in ' '.join(sys.path):
sys.path.append(VENDOR_ROOT) sys.path.append(VENDOR_ROOT)
# =================== # ===================
# = Global Settings = # = Global Settings =
# =================== # ===================
DEBUG = False
TEST_DEBUG = False TEST_DEBUG = False
SEND_BROKEN_LINK_EMAILS = False SEND_BROKEN_LINK_EMAILS = False
MANAGERS = ADMINS MANAGERS = ADMINS
@ -60,7 +62,7 @@ ADMIN_MEDIA_PREFIX = '/media/admin/'
SECRET_KEY = 'YOUR_SECRET_KEY' SECRET_KEY = 'YOUR_SECRET_KEY'
EMAIL_BACKEND = 'django_ses.SESBackend' EMAIL_BACKEND = 'django_ses.SESBackend'
CIPHER_USERNAMES = False CIPHER_USERNAMES = False
DEBUG_ASSETS = DEBUG
# =============== # ===============
# = Enviornment = # = Enviornment =

View file

@ -62,17 +62,6 @@
</script> </script>
{% include_stylesheets "common" %} {% 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 %} {% if not debug %}
<script type="text/javascript"> <script type="text/javascript">
@ -121,19 +110,16 @@
{% block content %}{% endblock %} {% block content %}{% endblock %}
{% if not debug %} {% block head_js %}
<!-- Start Quantcast tag --> {% include_javascripts "common" %}
<script type="text/javascript"> {% endblock head_js %}
_qoptions={ {% block extra_head_js %}
qacct:"p-0dE65XaLY51Og" {% endblock extra_head_js %}
};
</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 %}
<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> </body>
</html> </html>

View file

@ -2,8 +2,7 @@
{% load typogrify_tags recommendations_tags utils_tags statistics_tags %} {% load typogrify_tags recommendations_tags utils_tags statistics_tags %}
{% block content %} {% block extra_head_js %}
<script> <script>
$(document).ready(function() { $(document).ready(function() {
@ -12,6 +11,21 @@ $(document).ready(function() {
}); });
</script> </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 %}
<h1 class="NB-splash-heading">NewsBlur</h1> <h1 class="NB-splash-heading">NewsBlur</h1>
<h2 class="NB-splash-heading">- A visual feed reader with intelligence.</h2> <h2 class="NB-splash-heading">- A visual feed reader with intelligence.</h2>
@ -28,14 +42,6 @@ $(document).ready(function() {
<div class="NB-features-add"> <div class="NB-features-add">
<a href="#" id="add-feature-button" class="NB-splash-link">Add</a> <a href="#" id="add-feature-button" class="NB-splash-link">Add</a>
</div> </div>
<script>
$(document).ready(function() {
$('#add-feature-button').click(function(e) {
e.preventDefault();
$('#add-feature-form').fadeIn(500);
});
});
</script>
{% endif %} {% endif %}
<div class="NB-spinner NB-left"></div> <div class="NB-spinner NB-left"></div>
<a href="#" class="NB-module-direction NB-module-next-page NB-javascript"></a> <a href="#" class="NB-module-direction NB-module-next-page NB-javascript"></a>

View file

@ -36,7 +36,7 @@ class JammitAssets:
`use_compressed_assets` profile setting. `use_compressed_assets` profile setting.
""" """
tags = [] tags = []
if not settings.DEBUG: if not getattr(settings, 'DEBUG_ASSETS', settings.DEBUG):
if asset_type == 'javascripts': if asset_type == 'javascripts':
asset_type_ext = 'js' asset_type_ext = 'js'
elif asset_type == 'stylesheets': elif asset_type == 'stylesheets':